I tried these variations, but didn't succeed:
print calendar.monthcalendar(z,y)
print datetime.date(y,x,z).weekday()
print datetime.date(y,x,z).strftime('%A')
print calendar.monthcalendar(z,y)
print datetime.date(y,x,z).weekday()
print datetime.date(y,x,z).strftime('%A')
You have to convert user input (s
in the example below) to a datetime object. Then you can utilize strftime
to print the day of the week:
>>> import datetime
>>> s = "11.05.2015"
>>> d = datetime.datetime.strptime(s, "%d.%m.%Y")
>>> d
datetime.datetime(2015, 5, 11, 0, 0)
>>> d.strftime("%A")
'Monday'
You can create a time object from the time
module and then grab the weekday from calendar
:
calendar.day_name[time.strptime('11.05.2015', '%d.%m.%Y').tm_wday]