当前位置:天才代写 > tutorial > Python教程 > python显示生日是星期几

python显示生日是星期几

2018-05-17 08:00 星期四 所属: Python教程 浏览:314

python"># find the day of the week of a given date
# Python will trap impossible dates like (1900, 2, 29)
# tested with Python24     vegaseat    01aug2005

from datetime import date

# a typical birthday  year, month, day
# or change it to your own birthday...
birthday = date(1983, 12, 25)

dayList = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
# date.weekday() returns 0 for Monday and so on, so pick the day string from the dayList
print "The day of the week on %s was a %s" % (birthday.strftime("%d%b%Y"), dayList[date.weekday(birthday)])

标签:python

 

    关键字:

天才代写-代写联系方式