题解 | #计算日期到天数转换#
计算日期到天数转换
http://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
计算闰年的地方可能麻烦了点。
year, mount, day = input().split()
year, mount, day = int(year), int(mount), int(day)
long = [1, 3, 5, 7, 8, 10, 12]
if not year % 100 and not year % 400:
feb_days = 29
elif year % 100 and not year % 4:
feb_days = 29
else:
feb_days = 28
days = 0
for i in range(1, mount):
if i in long:
days += 31
elif i == 2:
days += feb_days
else:
days += 30
days += day
print(days)