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)
代码:
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)