使用python标准库判断闰年
import calendar
year = 2019
if calendar.isleap(year):
day_num=365
else:
day_num=366
calendar库中的闰年算法
def isleap(year):
"""Return True for leap years, False for non-leap years."""
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)