python如何判断是否是闰年 闰年共有366天 2月份多一天29天

python如何判断是否是闰年

def isRunYear(year):
    if (year % 100 == 0 and year % 400 == 0) or (year % 100 != 0 and year % 4 == 0):
        return True
    else:
        return False

year, month, day = map(int, input().split())
    
dic = {}
dic[1] = 31
dic[3] = 31
dic[5] = 31
dic[7] = 31
dic[8] = 31
dic[10] = 31
dic[12] = 31
dic[4] = 30
dic[6] = 30
dic[9] = 30
dic[11] = 30

if isRunYear(year):
    dic[2] = 29
else:
    dic[2] = 28
    
ans = 0
for i in range(1,month):
    ans += dic[i]
ans += day
print(ans)
 

posted @   bH1pJ  阅读(95)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示