python判断年份是否是闰年

python判断年份是否是闰年,第1张

群里有小伙伴找这个,就弄了下。

#!/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

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/714054.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-04-24
下一篇2022-04-24

发表评论

登录后才能评论

评论列表(0条)

    保存