
想问问这个是哪儿错了,如图所示,求第几月的第几天又怎么做呢?python函数
代码改正如下:
def is_leap(year):
# 判断year是否为闰年,闰年返回True,非闰年返回False
if (year % 100 != 0 and year % 4 == 0) or year % 400 == 0:
return True
else:
return False
def days_of_month(year,month):
# 根据输入的年月日,返回该月的天数
tian = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if is_leap(year):
tian[1] = 29
print(tian[month-1])
str = input("输入:")
year = int(str[0:4])
month = int(str[4:6])
days_of_month(year,month)