感觉自己写的代码还不错
class Fib(object): def __init__(self, num): self.num = num self.count = 0 def __str__(self): a,b,c = 0,0,1 n = self.num s = '[' while n: s +=str(b)+',' a,b = b,c c = a+b self.count+=1 n-=1 s = s[:-1]+']' return s def __len__(self): return self.count f = Fib(10) print f print len(f)