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

   

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

posted @ 2018-03-11 22:12  圆柱模板  阅读(856)  评论(0编辑  收藏  举报