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

计算日期到天数转换

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

# -*-coding:utf-8-*-
import calendar
while True:
    try:
        input_date = list(map(int , input().split(" ")))
        year = input_date[0]
        mouth = input_date[1]
        date = input_date[2]
        date_num = 0
        r_year = 0
        rm_date_num = 0
        if (year % 4 == 0) and year % 100 != 0 or year % 400 == 0:
        #if calendar.isleap(year):
            r_year = 1
        for m in range(1 , mouth):
            if m in (1 , 3 , 5 , 7 , 8 , 10 , 12):
                rm_date_num = 31
            elif m in (4 , 6 , 9 , 11):
                rm_date_num = 30
            elif m == 2 and r_year == 1:
                rm_date_num = 29
            elif m == 2 and r_year == 0:
                rm_date_num = 28
            date_num += rm_date_num
        print(date_num + date)
    except:
        break

全部评论

相关推荐

07-02 10:39
门头沟学院 Java
Steven267:说点真实的,都要秋招了,还没有实习,早干嘛去了,本来学历就差,现在知道急了,而且你这个简历完全可以写成一页,劣势太大了,建议转测试
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-11 11:16
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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