48课作业小甲鱼源代码有错误
求闰年的源代码少了一个定义#48_1
import datetime as dt
class LeapYear:
def __init__(self):
self.now = dt.date.today().year
def isLeapYear(self, year):
self.year = year#小甲鱼忘记写这个了
if (self.year%4 == 0 and self.year%100 != 0) or (self.year%400 == 0):
return True
else:
return False
def __iter__(self):
return self
def __next__(self):
while not self.isLeapYear(self.now):
self.now -= 1
temp = self.now
self.now -= 1
return temp
感谢分享!
页:
[1]