我对Python还比较陌生,遇到了一些麻烦,
涉及折叠或者更具体的说是reduce()
函数中的“initializer”参数。
例如:reduce(function, iterable[, initializer])
这里是函数...
>>> def x100y(x,y):
... return x*100+y
有人能解释一下为什么 reduce() 会产生44…的结果吗?
>>> reduce(x100y, (), 44)
44
或者为什么这里会产生30102错误...
>>> reduce(x100y, [1,2], 3)
30102
x100y
来自http://infohost.nmt.edu/tcc/help/pubs/python/web/reduce-function.html。 - Alok--