Week numbers in Python
How to get the week number from a date
To get the ISO week number (1-53), use
d is a date or datetime object.
To get the corresponding four-digit year (e.g. 2013), use
Read more about date.isocalendar() in the Python manual.
How to get the number of weeks in a year
To get the number of ISO weeks (i.e. the number of the last week) in a year, use
date(year, 12, 28).isocalendar().
year is an integer four-digit year.