reduce

1 from functools import reduce
2 
3 def add1(x,y):
4     return x + y
5 
6 print(reduce(add1,range(1,10)))
7 
8 
9 运行结果:45

 

posted @ 2018-11-01 14:18  疯狂的骆驼  阅读(157)  评论(0编辑  收藏  举报