Chinaunix首页 | 论坛 | 博客
  • 博客访问: 390316
  • 博文数量: 199
  • 博客积分: 154
  • 博客等级: 入伍新兵
  • 技术积分: 1530
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-14 08:43
文章分类

全部博文(199)

文章存档

2015年(101)

2014年(97)

2011年(1)

分类: Python/Ruby

2015-01-17 15:16:34

判断闰年条件, 满足年份模400为0, 或者模4为0但模100不为0. 
import time
thisyear = time.localtime()[0]
if thisyear % 400 == 0 or thisyear % 4 ==0 and thisyear % 100 != 0:
print ('this year %s is a leap year' % thisyear)
else:
print ('this year %s is not a leap year' % thisyear)

this year 2015 is not a leap year
阅读(952) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~