You can use the date
and datetime
modules in Python to get the date for the last day of the current week. Here's a code snippet that will do the job:
main.py139 chars7 lines
In the above code, today
is the current date, and weekday()
returns the day of the week as an integer (0 for Monday, 1 for Tuesday, etc.). So 6 - today.weekday()
gives the number of days from today to the end of the week (assuming Sunday is the last day of the week). We add this to today
to get the date for the last day of the week. The result is then printed using the print()
function.
gistlibby LogSnag