all Python 3datetimefunction
datetime.date.isoweekday()
datetime methods
Returns the ISO day of the week: 1 is Monday, 7 is Sunday. Unlike weekday(), the numbering starts at 1.
Syntax
date.isoweekday() -> int # 1=Mon … 7=Sun
Pick by what the number feeds into: weekday() is the one that indexes a zero-based list of day names, while isoweekday() lines up with the third field of isocalendar() and with ISO week numbering. Hence the classic off-by-one — the weekend is 5 and 6 under weekday() but 6 and 7 under isoweekday().
Examples
from datetime import date
d = date(2024, 6, 17) # понедельник
print(d.isoweekday()) # 1
print(d.weekday()) # 0
See also
Open in the full glossarydocs.python.orgReport an inaccuracy