def all_year(year):
cont =[]
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
#print("{0} 是闰年".format(year)) # 整百年能被400整除的是闰年
n = 29
else:
#print("{0} 不是闰年".format(year))
n = 28
else:
#print("{0} 是闰年".format(year)) # 非整百年能被4整除的为闰年
n = 29
else:
#print("{0} 不是闰年".format(year))
n = 28
for i in range(1,13):
if i==2:
t = n
elif i in [4,6,9,11]:
t = 30
else:
t = 31
if i<10:
yy = '0'+str(i)
else:
yy = str(i)
for e in range(1,t+1):
if e<10:
y = '0'+str(e)
else:
y = str(e)
r = str(year)+'-'+yy+'-'+y
cont.append(r)
print(len(cont))
return cont
python获取指定年份的所有日期
最新推荐文章于 2023-06-27 02:14:40 发布