import itertools as it
accumulate
it.accumulate(data, function)
data是一个可迭代对象function可以是普通函数,也可以是无名函数lambda- 列子:
max:python自定义的最大值函数;lambda x,y:x+y无名函数
- 列子:
permutations
it.permutations(range(1, 4))
使用zip合并两个迭代器
for i, s in zip(range(11), it.accumulate(range(11))):
pass
filtertrue和filterfalse:对迭代器进行过滤
it.filterfalse(lambda n: n % 13, range(100))