1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| 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)
|