歪瑞easy的一题!
####判断是否是闰年 def leap_year(year): if year%100==0: if year%4==0: flag=True else: flag=False else: if year%4==0: flag=True else: flag=False return flag #定义月份 days=[31,0,31,30,31,30,31,31,30,31,30,31] while True: try: y, ***p(int, input().strip().split()) #先抛出异常 if (y<0 or m<1 or m>12 or d<1 or d>31 or (m==2 and d>29)): print(-1) break else: #进入正题 if m==1: print(d) elif m==2: print(31+d) else: if leap_year(y): days[1]=29 result=sum(days[:(m-1)])+d print(result) else: days[1]=28 result=sum(days[:(m-1)])+d print(result) except: break