python3不能直接使用reduce()函数,因为reduce() 函数已经被从全局名字空间里移除了,它现在被放置在fucntools 模块里,所以要使用reduce函数得先饮用fucntools

例如:

>>> from functools import reduce

>>> reduce(lambda x,y:x+y,[1,2,3,4,5])

15

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 2021-07-17
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-06-24
  • 2021-05-01
  • 2022-12-23
相关资源
相似解决方案