Python3 reduce()函数

函数作用:

  • 阶乘和的计算。

与python2差异

  • python 3 中,reduce()函数已从全局函数中移除,放置在functools模块中,使用的话需要调用此模块中的reduce
  • 例子:
    from functools import reduce

     

  • 而在Python2 中直接使用即可

 

posted @ 2020-03-12 23:33  局长  阅读(961)  评论(0编辑  收藏  举报