题解 | #日期差值#

日期差值

https://www.nowcoder.com/practice/ccb7383c76fc48d2bbc27a2a6319631c

from datetime import datetime, timedelta


def split_time(str):
    year = str[0:4]
    month = str[4:6]
    day = str[6:]
    return int(year), int(month), int(day)


str1 = input()
str2 = input()
year1, month1, day1 = split_time(str1)
year2, montn2, day2 = split_time(str2)
datetimeobj1 = datetime(year1,month1,day1)
datetimeobj2 = datetime(year2, montn2, day2)
delta=datetimeobj2-datetimeobj1

print("{}".format(delta.days+1), end="\n")

全部评论

相关推荐

三年之期已到我的offer快到碗里来:9硕都比不上9本
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务