为了账号安全,请及时绑定邮箱和手机立即绑定

reduce()函数也是Python内置的一个高阶函数。

reduce()函数也是Python内置的一个高阶函数。

正在回答

1 回答

是的,注意底下加粗的部分

Help on built-in function reduce in module __builtin__:

reduce(...)

    reduce(function, sequence[, initial]) -> value

    Apply a function of two arguments cumulatively to the items of a sequence,

    from left to right, so as to reduce the sequence to a single value.

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

    ((((1+2)+3)+4)+5).  If initial is present, it is placed before the items

    of the sequence in the calculation, and serves as a default when the

    sequence is empty.


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
python进阶
  • 参与学习       255533    人
  • 解答问题       3038    个

学习函数式、模块和面向对象编程,掌握Python高级程序设计

进入课程

reduce()函数也是Python内置的一个高阶函数。

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号