[Python] python显示生日是星期几 →→→→→进入此内容的聊天室

来自 , 2019-06-25, 写在 Python, 查看 101 次.
URL http://www.code666.cn/view/0a118184
  1. # find the day of the week of a given date
  2. # Python will trap impossible dates like (1900, 2, 29)
  3. # tested with Python24     vegaseat    01aug2005
  4.  
  5. from datetime import date
  6.  
  7. # a typical birthday  year, month, day
  8. # or change it to your own birthday...
  9. birthday = date(1983, 12, 25)
  10.  
  11. dayList = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
  12. # date.weekday() returns 0 for Monday and so on, so pick the day string from the dayList
  13. print "The day of the week on %s was a %s" % (birthday.strftime("%d%b%Y"), dayList[date.weekday(birthday)])
  14. #//python/5750

回复 "python显示生日是星期几"

这儿你可以回复上面这条便签

captcha