python闰年判断 从儒略历到格里高利历 公历历史
上大学时学编程,老师和教材都告诉我,闰年的判断有两个原则:
1)能被4正确,且不能被100整除,则是闰年;
2)能被100整除,且不能被400整除,则是闰年。
今年看了一个python闰年判断的代码,惊得下巴都掉地上了。代码如下:
year = int(input("Enter a year: "))
# Display its status.
if year % 4 != 0 or (year % 100 == 0 and year > 1582 and year % 400 != 0)
原创
2021-01-30 23:09:26 ·
646 阅读 ·
0 评论