代码如下:yunx
import arrow
def getAllYearDate(year: int):
"""
:param year: 年份,eg:2022、2023等
:return:
"""
date_list = []
start_date = '%s-1-1' % year
a = 0
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
days_sum = 366
else:
days_sum = 365
while a < days_sum:
b = arrow.get(start_date).shift(days=a).format("YYYYMMDD")
a += 1
date_list.append(b)
return date_list
print(getAllYearDate(2023))
运行结果如下: