手机
当前位置:查字典教程网 >脚本专栏 >python >python显示生日是星期几的方法
python显示生日是星期几的方法
摘要:本文实例讲述了python显示生日是星期几的方法。分享给大家供大家参考。具体实现方法如下:#findthedayoftheweekofagi...

本文实例讲述了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程序设计有所帮助。

【python显示生日是星期几的方法】相关文章:

Python GAE、Django导出Excel的方法

Python调用C/C++动态链接库的方法详解

python实现跨文件全局变量的方法

python中的sort方法使用详解

wxpython 最小化到托盘与欢迎图片的实现方法

wxpython中利用线程防止假死的实现方法

python中使用urllib2伪造HTTP报头的2个方法

python paramiko实现ssh远程访问的方法

python迭代器的使用方法实例

python批量导出导入MySQL用户的方法

精品推荐
分类导航