temp = input("请输入一个年份:") while not temp.isdigit(): print("您的输入不合法") temp = input("请输入一个年份:") year = int(temp) if (year %4==0 and year %100 !=0) or year%400 ==0: print("您输入的年份是闰年") else: print("您输入的年份不是闰年")
temp = input("请输入一个年份:") while not temp.isdigit(): print("您的输入不合法") temp = input("请输入一个年份:") year = int(temp) if (year %4==0 and year %100 !=0) or year%400 ==0: print("您输入的年份是闰年") else: print("您输入的年份不是闰年")
原文:https://www.cnblogs.com/sunshining-f/p/8624532.html