from datetime import datetime
print(datetime.strptime("2023-06-07", '%Y-%m-%d').weekday() + 1)
输出:3
安装库 pip install chinesecalendar,该库仅支持至当前年,即23年使用时无法知晓24年的法定假期
from chinese_calendar import is_workday, is_holiday
print(is_workday(datetime.strptime("2023-06-11", '%Y-%m-%d')))
输出:False
print(is_holiday(datetime.strptime("2023-06-11", '%Y-%m-%d')))
输出:True
from chinese_calendar import get_holiday_detail
print(get_holiday_detail(datetime.strptime("2023-06-24", '%Y-%m-%d')))
输出:(True, 'Dragon Boat Festival')