题解 | #计算日期到天数转换#
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
y, m, d = list(map(int, input().split())) yun = False if y % 400 == 0 or (y % 100 != 0 and y % 4 == 0): # 判断是否是闰年,逢百年不闰,四百年一闰 yun = True ylist = [31,28,31,30,31,30,31,31,30,31,30,31] sum = 0 for i in range(m-1): # 累加前年已经满了的月份 sum += ylist[i] sum += d # 加上当前月 if m > 2 and yun: #闰年且月份大于2 sum += 1 print(sum)