python判断当天是否是工作日
from chinese_calendar import is_workday from datetime import datetime # 判断所给日期是否为交易日 # https://blog.csdn.net/wzk4869/article/details/129814670 def isTradeDay(date): if is_workday(date): if datetime.isoweekday(date) < 6: return True return False if __name__ == '__main__': date1 = '2023-07-16' date = datetime.strptime(date1, '%Y-%m-%d').date() print("时间:", date1) print("是工作是?", isTradeDay(date)) print("当前时间是工作?", isTradeDay(datetime.now()))