1.能被400整除的年份
2.能被4整除,但是不能被100整除的年份
以上2种方法满足一种即为闰年
temp = input('请输入年份:')
while not temp.isdigit():
temp = input('不是整数,请重新输入: ',end = '')
year = int(temp)
if (year/400 == int(year/400)):
print('该年份是闰年')
else:
if year/4 == int(year/4) and year/100 != int(year/100) :
print('该年份是闰年')
else:
print('该年份不是闰年')
最后
以上就是冷艳电灯胆最近收集整理的关于Python(判断闰年)的全部内容,更多相关Python(判断闰年)内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复