zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python应用-传入年月日 输出为一年的第几天

Python应用输出 一年 传入 年月日 第几天
2023-09-14 08:57:35 时间

   

ef leap_year(year):
    return  (year//4==0 and year//100!=0) or (year //400==0)
def which_day(year,month,day):
    total=0
    days_of_month=[31,28,31,30,31,30,31,31,30,31,30,31]
    for index in range (month-1):
            total += days_of_month[index]
    if month >2 and leap_year(year):
        total += 1
    return total + day
if __name__ == '__main__':
    print(which_day(1980,11,28))

  结果: 332