datetime.datetime.weekday()
to get the day of the week as an integer.4
.d
, to use a default value of datetime.today()
.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! ✌️