python根据日期判断星期几(超简洁)

代码:

from datetime import datetime


def getWeek(week):
    print(date + "是星期" + str(week + 1))


date = input("请输入你要计算的日期(格式如下:20220101):")
week = datetime.strptime(date, "%Y%m%d").weekday()
getWeek(week)

 

posted @ 2022-03-21 19:25  睡觉不困  阅读(591)  评论(0编辑  收藏  举报