1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| def count(year,month,day):
count = 0
if year%400==0 or (year%4==0 and year%100!=0):
print(f'{year}年是闰年,2月份有29天!')
li1 = [31,29,31,30,31,30,31,31,30,31,30,31]
for i in range(month-1):
count += li1[i]
return count+day
else:
print(f'{year}年是平年,2月份有28天!')
li2 = [31,28,31,30,31,30,31,31,30,31,30,31]
for i in range(month-1):
count += li2[i]
return count+day
if __name__ == "__main__":
today = [2022,7,2]
count = count(today[0],today[1],today[2])
print(f'{today[0]}年{today[1]}月{today[2]}日是今年的第{count}天!')
|