一推网

当前位置: 首页 > 知识问答 > python判断闰年

知识问答

python判断闰年

2026-11-22 17:53:19 来源:互联网转载

#-*- coding:utf-8 -*-try:  year = int(raw_input('请输入年份(如2008): '))except:  print '请输入正确的年份'  exit()is_leap = Falseif year % 100 == 0 and year % 400 == 0:  is_leap = Trueelif year % 100 != 0 and year % 4 == 0:  is_leap = Trueif is_leap:  print '%d年是闰年!' % yearelse:  print '%d年不是闰年!' % year

python判断闰年

上一篇:vue动态路由是什么意思

下一篇:word不小心关闭没保存怎么恢复