datetime.datetime.weekday()to get the day of the week as an integer.
d, to use a default value of
from datetime import datetime def is_weekday(d = datetime.today()): return d.weekday() <= 4
from datetime import date is_weekday(date(2020, 10, 25)) # False is_weekday(date(2020, 10, 28)) # True
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️