好人求解!!!
class Fib(object):
def __init__(self, num):
a, b, L = 0, 1, []
self.num=num
for n in range(num):
L.append(a)
a, b = b, a + b
self.numbers = L
def __str__(self):
return str(self.numbers)
__repr__ = __str__
def __len__(self):
return len(self.numbers)
f = Fib(10)
print f
为什么打印出来的仅仅只是L,而没有返回它的长度啊??class里不是有 return len(self.numbers)了吗?