题解 | #日期差值#
日期差值
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")