1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import datetime def date_range(start_date, end_date): for n in range(int((end_date - start_date).days)): yield start_date + datetime.timedelta(n) #start = datetime.datetime(2014, 11, 26, 0, 0, 0) start = datetime.datetime.strptime("20230101", "%Y%m%d") end = datetime.datetime.now() for i in date_range(start, end): weekday = i.weekday() + 1 if weekday == 6 or weekday == 7: continue print(i.strftime('%Y%m%d')) |
refer to:
https://www.cnblogs.com/ChenKeng/articles/4141791.html
https://www.zkxjob.com/48467