判断闰年条件, 满足年份模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
阅读(1007) | 评论(0) | 转发(0) |