Python写一个根据日期计算是星期几的模块

import datetime
def get_week_day(date):
week_day = {
0: '星期一',
1: '星期二',
2: '星期三',
3: '星期四',
4: '星期五',
5: '星期六',
6: '星期日',
}
day = date.weekday() #weekday()可以获得是星期几
return week_day[day]
print(datetime.datetime.now())
print(get_week_day(datetime.datetime.now()))
posted @ 2016-11-23 16:17  幽梦  阅读(2863)  评论(0编辑  收藏  举报