最新回答 / DanDanHang
<...code...>自己解读下这句话,应该对你有帮助 If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.
2015-04-07
最赞回答 / a412739861
不是,Fib(n)中的n其实匹配的是for n in range(num)中的num,进行了num次迭代。循环是为了构成n个斐波那契数列,你把for n in的n换成x也是可以的。
2015-04-05
最新回答 / DanDanHang
是的,注意底下加粗的部分Help on built-in function reduce in module __builtin__:reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the se...
2015-04-05
最赞回答 / lhclylzl
当含有其他类是,可以判断其他类的类型。例如有数字和字符串,数字和分数比较,字符串和名字比较 def __cmp__(self, s): if isinstance(s,Student): if self.score<s.score: return -1 elif self.score>s.score: return 1 else: ...
2015-04-05