temp = input('请输入一个年份:')
while not temp.isdigit():
temp = input("抱歉,您的输入有误,请输入一个整数:")
year = int(temp)
while not (year/400 == int(year/400)) and (year/4 == int(year/4) or year/100 !=int(year/100)):
#想把这个程序一直运行下去,可以输入任何一个数字看看是否是闰年。
temp = input("继续努力试试吧:")
year = int(temp)
if year/400 == int(year/400):
print(temp + ' 是闰年!')
else:
if (year/4 == int(year/4)) and (year/100 != int(year/100)):
print(temp + ' 是闰年!')
else:
print(temp + ' 不是闰年!') while True:
x = input('请输入年份 : ') . strip()
if x:
y = int(x)
if y > 0 :
if y % 4 == 0 and y % 100 != 0 or y % 400 == 0:
print(y , '是闰年')
else:
print(y , '不是闰年')
else:
break
else:
break
页:
[1]