import arrow
import datetime
from chinese_calendar import is_workday
def isLeapYear(years):
if ((years % 4 == 0 and years % 100 != 0) or (years % 400 == 0)):
days_sum = 366
return days_sum
else:
days_sum = 365
return days_sum
def getAllDayPerYear(years):
start_date = '%s-1-1' % years
a = 0
all_date_list = []
days_sum = isLeapYear(int(years))
print()
while a < days_sum:
b = arrow.get(start_date).shift(days=a).format("YYYY-MM-DD")
a += 1
all_date_list.append(b)
return all_date_list
if __name__ == '__main__':
result=[]
all_date_list = getAllDayPerYear("2023")
for date in all_date_list:
if is_workday(datetime.datetime.strptime(date, "%Y-%m-%d")):
continue
else:
result.append(date)
print (result)
可以计算调休,比较完整。