python显示生日是星期几的方法
2015-05-27 00:00
495 查看
本文实例讲述了python显示生日是星期几的方法。分享给大家供大家参考。具体实现方法如下:
希望本文所述对大家的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在vim中的高亮显示设置方法…
- 黄聪:python控制台无法正常显示中文字符串解决方法
- python 读取并显示图片的两种方法
- Python使用Matplotlib模块时坐标轴标题中文及各种特殊符号显示方法
- Python中文竖排显示的方法
- ubuntu下python的图像显示,读取方法
- Python读取并显示图片的两种方法
- 基于Linux系统中python matplotlib画图的中文显示问题的解决方法
- 通过python直接显示json格式数据的方法
- Python 3下Matplotlib画图中文显示乱码的解决方法
- Python DataFrame 设置输出不显示index(索引)值的方法
- 在Python的Django框架中显示对象子集的方法
- Python 操作MySQL中文显示乱码的解决方法
- Python的raw_input语句包含中文,在Windows环境CMD中显示乱码的解决方法
- python tkinter界面居中显示的方法
- Python在Console下显示文本进度条的方法
- Python 3下Matplotlib画图中文显示乱码的解决方法
- python Wing IDE编辑器的中文显示解决方法
- python简单图片操作:打开\显示\保存图像方法介绍