year = int(input("请输入年份:"))
month = int(input("请输入月份:"))
day = int(input("请输入日期:"))
def calendar(year,month,day):
product=0
if year % 400 == 0 or (year % 100 != 0 and year % 400 == 0) : #闰年的情况
month_s=[0,31,29,31,30,31,30,31,31,30,31,30,31]
# for i in range(0, 11) :
month=[31,29,31,30,31,30,31,31,30,31,30,31]
product = product + month_s[ month-1 ] + day
else : #平年的情况
month_s1=[0,31,28,31,30,31,30,31,31,30,31,30,31]
# for h in range(0, 12):
product = product + month_s1[month-1] + day
return product
print(calendar(year,month,day))
不知道你要的是不是这样。 挂号全打少了。 遍历列表,是把所有月份都加了一遍,不知道你的用意。自己感受吧。。。 |