html5中文学习网

您的位置: 首页 > 网站及特效实例 > jquery特效 » 正文

python显示生日是星期几的方法_编程语言综合

[ ] 已经帮助:人解决问题

   本文实例讲述了python显示生日是星期几的方法。分享给大家供大家参考。具体实现方法如下:DMFHTML5中文学习网 - HTML5先行者学习网

  ?DMFHTML5中文学习网 - HTML5先行者学习网

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程序设计有所帮助。DMFHTML5中文学习网 - HTML5先行者学习网

(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助