群里有小伙伴找这个,就弄了下。
#!/usr/bin/python3
# -*- coding: utf-8 -*-
while True:
try:
year = int(input("输入年份:"))
if year%4 == 0 and year%100 !=0 or year%400 == 0:
print("{}闰年".format(year))
continue
else:
print("{}非闰年".format(year))
continue
except Exception as e:
print("输入字符非整数,请输入正确数字!")
continue