输入格式为YYYYMMDD的字符串日期,计算并返回这一天是这一年的第几天,需完善给定的Python函数代码。
getDaysyear,字符串类型,格式如"20211201"def getDays(year):
s = 0
y = int(year[:4])
m = int(year[4:6])
d = int(year[6:8])
monthdays = (31,28,31,30,31,30,31,31,30,31,30,31)
for i in range( ① ):
s = s + ②
if (y % 4 ==0 and y % 100 !=0 or y % 400 ==0) and ③ :
s = s + 1
s = s + d
return s
year = "20211201"
theday = ④
print(theday)