python内置函数

1、reduce() 函数会对参数序列中元素进行累积。

reduce() 函数语法:

reduce(function, iterable[, initializer])

例:

from functools import reduce
s = reduce(lambda x,y:x+y,range(1,10))
print(s) #45
posted @ 2020-04-06 00:11  智、心  阅读(118)  评论(0编辑  收藏  举报