思路:先把月份转化为天数,再加上第几天。 但,要判断是闰年还是平年
# 用户输入的部分
year = int(input('Please enter a year:\n'))
mouth = int(input('Please enter a month:\n'))
day = int(input('Please enter the number of days:\n'))
# 月份转化为天数,以平年为准
mouths = (0, 31, 59, 90, 120, 151, 181, 212, 243, 173, 304, 334)
if 0 < mouth <= 12:
sum1 = mouths[mouth-1]
else:
print('Date Error !')
# 再判断是闰年还是平年
sum1 += day # 这里sum1 就表示总天数
if(year % 400 == 0)or(year % 4 == 0)and(year % 100 != 0):
if mouth > 2:
sum1 += 1
print(f'it is the {sum1} day !\n')