python菜鸟写的关于__len__()章节的任务,运行出来总是回我一个空的[]和0
class Fib(object): count=[] def __init__(self, num): self.num=num def fab(self): if self.num==1: Fib.count.append(0) Fib.count.append(1) elif self.num==0: Fib.count.append(0) else: Fib.count.append(0) Fib.count.append(1) for n in range(self.num): c=int(fab(n-1))+int(fab(n-2)) Fib.count.append(c) def __str__(self): return str(Fib.count) __repr__ = __str__ def __len__(self): return len(Fib.count) f=Fib(10) print f print len(f)