reduce,过程:
reduce

由此可以看出,过程,reduce第一个参数是函数表达式lambda,第二个是参数,第三个是初始值

x,y,取前两个数字
然后x选取算起来的和,y取后面一个数字

from functools import reduce
list_x = [1,2,3,4,5,6,7,8,9]
r = reduce(lambda x,y: x+y, list_x)
print®

reduce

相关文章:

  • 2021-05-10
  • 2021-06-08
  • 2021-09-13
  • 2021-11-14
  • 2021-09-18
  • 2021-09-29
  • 2021-07-27
  • 2021-09-21
猜你喜欢
  • 2021-04-08
  • 2021-05-25
  • 2021-11-07
  • 2021-04-14
  • 2021-08-20
相关资源
相似解决方案