import datetime today = datetime.datetime.now().weekday() + 1 print(today) # 输出5
import datetime week = datetime.datetime.strptime("20210903", "%Y%m%d").weekday() + 1 print(week) # 输出5