#-*- coding:utf8 -*-
days1=[31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]
days2=[31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]
print ("-------------------------------------")
date = str(input("请输入你要查询的年月日,例如:20200506\n"))
year = int(date[0:4])
month = int(date[4:6])
day = int (date[6:8])
if year%4 != 0:
year_day_all = 365
days11 = int(days1[month - 2])
result = days11 + day
print ("从年初到今天已经过了",result,"天了")
print ("-------------------------------------")
else:
year_day_all = 366
days12 = int(days2[month - 2])
result = days12 + day
print ("从年初到今天已经过了",result,"天了")
print ("-------------------------------------")
|