importcalendar
year=2019
ifcalendar.isleap(year):
day_num=365
else:
day_num=366
calendar庫中的閏年算法
defisleap(year):
"""ReturnTrueforleapyears,Falsefornon-leapyears."""
returnyear%4==0and(year%100!=0oryear%400==0)
importcalendar
year=2019
ifcalendar.isleap(year):
day_num=365
else:
day_num=366
calendar庫中的閏年算法
defisleap(year):
"""ReturnTrueforleapyears,Falsefornon-leapyears."""
returnyear%4==0and(year%100!=0oryear%400==0)