题解 | #计算日期到天数转换#
计算日期到天数转换
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