python 3.0以后, reduce已经不在built-in function里了, 要用它就得from functools import reduce.

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.

意思就是对sequence连续使用function, 如果不给出initial, 则第一次调用传递sequence的两个元素, 以后把前一次调用的结果和sequence的下一个元素传递给function. 如果给出initial, 则第一次传递initial和sequence的第一个元素给function

*functool标准库还有很多功能,可以参考网上的资料

最新文章

  1. eclipse 突然 一直在loading descriptor for XXX (XXX为工程名)Cancel Requested
  2. OC 观察者模式(通知中心,KVO)
  3. [经验交流] 为 mesos framework 分配资源
  4. java_method_stringUtils
  5. 样条函数 -- spline function
  6. myeclipse启动tomcat会出现 a java exception has occured错误 的解决方法
  7. c++实现排序(简单插入,希尔,选择,快速,冒泡,堆排)
  8. java运行内存分配图(转)
  9. 问对于一个给定的n,怎样才能用最少的步骤将它变到1
  10. 网页设计师必备的10个CSS技巧
  11. 用iframe设置代理解决ajax跨域请求问题
  12. openerp经典收藏 深入理解报表运行机制(转载)
  13. 通过WebApi取出XML数据
  14. hdu 4775 Infinite Go(暴力)
  15. ds18b20再硬件设计部分的注意事项
  16. MONO 如何打包 .NET程序独立运行(winform篇)
  17. 201521123104《Java程序设计》第1周学习总结
  18. DRAM的原理设计
  19. python中split()的用法
  20. apollo入门demo实战(二)

热门文章

  1. Ant 编译项目资源不足
  2. 基于Linux的智能家居的设计(5)
  3. DNS的概念,用途,DNS查询的实现算法
  4. TensorFlow学习笔记 速记2 报错:failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_INVALID_DEVICE
  5. Mysql备份工具比较
  6. 开源码应用之Eclipse篇
  7. linux服务器宕机分析/性能瓶颈分析
  8. virtualBox centos 6.x不能联网
  9. java 提取数据
  10. 利用JNDI的命名与服务功能来满足企业级API对命名与服务的访问