求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)