欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

输入某年某月某日,判断这一天是这一年的第几天?

程序员文章站 2022-06-11 16:04:01
if __name__=="__main__": a=[[31,28,31,30,31,30,31,31,30,31,30,31],[31,29,31,30,31,30,31,31,30,31,30,31]] year=int(input("请输入需要判断的年:")) month = int(inp ......
if __name__=="__main__":
    a=[[31,28,31,30,31,30,31,31,30,31,30,31],[31,29,31,30,31,30,31,31,30,31,30,31]]
    year=int(input("请输入需要判断的年:"))
    month = int(input("请输入需要判断的月:"))
    day = int(input("请输入需要判断的日:"))
    sum=0
    if (year%4==0 and year%100!=0)or year%400==0:
        for i in range(1,month):
            sum=sum+a[1][i]
    else:
        for i in range(1,month):
            sum=sum+a[0][i]
    sum=sum+day
    print("{}年{}月{}日是这一年的第:{}天".format(year,month,day,sum))