老方法
year = int(input("请输入一个年份:"))
if (year % 4) == 0 and (year % 100) != 0 or (year % 400) == 0:
print("{0}是闰年".format(year))
else:
print("{0}不是闰年".format(year))
这个就是很简单,能看懂得方法了,这个是多语句一起用,也可以分开写,看你方便习惯
其实calendar里面有个判断闰年的函数isleap()
import calendar
year = int(input("请输入年份:"))
check_year=calendar.isleap(year)
if check_year == True:
print ("闰年")
else:
print ("平年")