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获取指定年份的所有日期的全部内容,更多相关python获取指定年份内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复