from functools importreducedeffact(n):returnreduce(lambda a, b: a * b,range(1, n +1))print(fact(5))from operator import muldeffact1(n):returnreduce(mul,range(1, n +1))print(fact1(5))
from operator import methodcallers ='the time has come'
upcase = methodcaller('upper')# 调用指定的方法 'upper'print(upcase(s))# THE TIME HAS COME
connect = methodcaller('replace',' ','-')print(connect(s))# the-time-has-come
from operator import mul
from functools import partialtriple = partial(mul,3)print(triple(7))# 21print(list(map(triple,range(1,10))))# [3, 6, 9, 12, 15, 18, 21, 24, 27]
http://blog.csdn.net/pipisorry/article/details/37055183python数字处理简介数字类型python没有unsighed int:The Python int is an abstraction of an integer value, not a direct access to a fixed-byte-size integer.不过int还是当成sighed int处理的&#x…
上一篇我们手写了HashMap,还有一个很重要的Map的实现类TreeMap。打开源码第一句话:* A Red-Black tree based {link NavigableMap} implementation.TreeMap是一个基于红黑树的实现。对红黑树没有了解怎么办,那就先搞清楚红黑树的原理。只要理…