python编程实例 计算某天是这一年的第几天

点击查看代码
def isRunNian(year):
    if((year%400 == 0) or (year%4==0 and year%100!=0)):
        return 1
    else:
        return 0
tianshu=[31,28,31,30,31,30,31,31,30,31,30,31]
year=int(input("year:"))
month=int(input("month:"))
day=int(input("day:"))
if(isRunNian(year)):
    tianshu[1]=tianshu[1]+1
sum=0
for i in range(month):
    sum+=tianshu[i]
sum+=day
print("第",sum,"天")

​​

posted on 2024-07-12 10:04  我坚信阳光灿烂  阅读(10)  评论(0编辑  收藏  举报

导航