Python 判断闰年并计算年份天数
def g(n):
if n % 4 == 0 and n % 100 != 0 or n % 400 == 0:
return True
else:
return False
year = int(input('请输入年份:'))
while year <= 0:
year = int(input('请输入年份:'))
if g(year):
print('{}年有366天'.format(year))
else:
print('{}年有365天'.format(year))
原文地址: https://www.cveoy.top/t/topic/oDxt 著作权归作者所有。请勿转载和采集!