year=int(input("请输入年份: "))
mouth=int(input(“请输入月份 “))
day=int(input(“请输入天数: “))
l=[0,31,59,90,120,151,181,212,243,273,304,334]
if(0<=mouth<=12 and 1<=day<=31):
sum = l[mouth - 1]
sum = sum + day
if (year % 400 == 0 or (year % 100 != 0 and year % 4 == 0)):
sum = sum + 1
print(”{}年的第{}天”.format(year, sum))
else:
print(”{}年的第{}天”.format(year, sum))
else:
print(“哎呀,月份或者日期输入错了哦!”)
用python求末年某月某日是一年中的第几天
最新推荐文章于 2024-10-30 13:16:11 发布