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)])

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8301.html

(0)
上一篇 2021年7月18日
下一篇 2021年7月18日

相关推荐

发表回复

登录后才能评论