python reduce 函数

reduce 函数,是对一个列表里的元素做累计计算的一个函数。接收两个参数(函数,序列)例如

1 def num(x,y)
2     return x+y
3 
4 reduce(num,[1,2,3,4,5,6])
5 
6 返回21
View Code

就是对一个序列做累计操作

原文地址:https://www.cnblogs.com/pxfb/p/6893310.html