题解 | #计算日期到天数转换#

计算日期到天数转换

https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded

import sys


L = input().split()
year =int(L[0])
month =int(L[1])
day = int(L[2])

dict={}
dict["month1"]=31
dict["month2"]=28
dict["month3"]=31
dict["month4"]=30
dict["month5"]=31
dict["month6"]=30
dict["month7"]=31
dict["month8"]=31
dict["month9"]=30
dict["month10"]=31
dict["month11"]=30
dict["month12"]=31


#能被4整除的情况下,如果还能被100整除,不能被400整除,不是闰年
if year%4==0 :
    if year%100 ==0:
        if year%400==0:
            dict['month2']=29
        else:
            pass
    else:
        dict["month2"]=29
    

for i in range(1,month):
    day+= dict["month" + str(i)]
print(day)

全部评论

相关推荐

每晚夜里独自颤抖:要求太多的没必要理
点赞 评论 收藏
分享
机械打工仔:我来告诉你原因,是因为sobb有在线简历,有些HR为了快会直接先看在线简历,初步感觉不合适就不会找你要详细的了
投了多少份简历才上岸
点赞 评论 收藏
分享
07-02 13:52
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务