欢迎来到山村网

python显示生日是星期几的方法

2019-03-02 13:24:25浏览:882 来源:山村网   
核心摘要:  本文实例讲述了python显示生日是星期几的方法。分享给大家供大家参考。具体实现方法如下:  ? 12345678910# find the day

  本文实例讲述了python显示生日是星期几的方法。分享给大家供大家参考。具体实现方法如下:

  ?

1 2 3 4 5 6 7 8 9 10 # 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程序设计有所帮助。

(责任编辑:豆豆)
下一篇:

python类继承用法实例分析

上一篇:

python中zip和unzip数据的方法

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com