Python判断是否是闰年

year = 2012
if year % 100 != 0 and year % 4 == 0:
    print('闰年')
elif year % 100 == 0 and year % 400 == 0:
    print('闰年')
else:
    print('平年')

 或者

print('*'*100)
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
    print('闰年')
else:
    print('平年')

四年一闰 百年不闰 四百年再闰

编写程序,给定一个日期,输出这个日期是这一年的第几天?

1. datetime.datetime.strftime

2. 判断平年闰年

原文地址:https://www.cnblogs.com/zhzhang/p/11263713.html