__author__ = 'gate_007' #encoding:utf-8 import time def isLeapYear(): print "time.localtime() : %s" % time.localtime() year = time.localtime()[0] print '%d' %year if( year % 400 ==0 or (year % 4 == 0 and year % 100 != 0)): print '%d is Leap year' %year if __name__ == '__main__':isLeapYear()
Test result:
Connected to pydev debugger (build 139.1001) time.localtime() : time.struct_time(tm_year=2016, tm_mon=1, tm_mday=2, tm_hour=11, tm_min=57, tm_sec=16, tm_wday=5, tm_yday=2, tm_isdst=0) 2016 2016 is Leap year Process finished with exit code 0
isLeapYear
最新推荐文章于 2024-05-03 18:03:53 发布