python显示生日是星期几的方法
更新时间:2015年05月27日 12:46:39 作者:依山带水
这篇文章主要介绍了python显示生日是星期几的方法,涉及Python使用date模块操作日期的技巧,需要的朋友可以参考下
本文实例讲述了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程序设计有所帮助。
相关文章
pdf论文中python画的图Type 3 fonts字体不兼容的解决方案
这篇文章主要介绍了pdf论文中python画的图Type 3 fonts字体不兼容的解决方案,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2021-04-04Python中enumerate()函数编写更Pythonic的循环
本篇文章主要大家通过实例讲述了Python中enumerate()函数编写更Pythonic的循环的知识点,有兴趣的朋友参考学习下。2018-03-03
最新评论