我正在使用 Python 3.2。试过这个:
xor = lambda x,y: (x+y)%2
l = reduce(xor, [1,2,3,4])
并得到以下错误:
l = reduce(xor, [1,2,3,4])
NameError: name 'reduce' is not defined
尝试将 reduce
打印到交互式控制台 - 收到此错误:
NameError: name 'reduce' is not defined
reduce
真的在 Python 3.2 中被移除了吗?如果是这样的话,还有什么办法呢?
最佳答案
已移至 functools
.
关于python - 名称错误 : name 'reduce' is not defined in Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8689184/