I want to create a function that gives last week with the year
for example, the current week number is 19, so the function should give the result 2023_W18
. And the weeks should start from Monday to Sunday. So I run the script on Monday, and it will give last week's number.
I found a few examples:
>>> import datetime
>>> datetime.date(2010, 6, 16).isocalendar()[1]
24
but how to get last week's number? Do I need to first subtract 7 days from the current day? It should also support when the year change.