python 标准库 算法

1、functools.partial()
包含函数进去

image.png

获取属性:functools.update_wrapper()
image.png

image.png

update_wrapper()的修饰符:functools.wraps()
2、富比较,只需提供eq和gt,lt等中的一个就可以:
@functools.total_ordering
image.png

提供sorted的cmp_to_key???
3、itertools.chain
image.png

itertools.izip
image.png

islice??
tee
image.png

imap
image.png

startmap生成元组
image.png

count(1) 从1开始计数
image.png

cycle循环
image.png

repeat
image.png

dropwhile第一次为false之后的所有元素
image.png

takewhile
image.png

ifilter筛选
image.png

ifilterfalse
image.png

check_item()
groupby:按属性x
image.png

4、operator比较
image.png

lt le eq ne ge gt
image.png

abs neg pos add div floordiv mod pow sub truediv
image.png

contains countOf indexOf
image.png

isMappingType isNumberType isSequenceType
image.png

5、contextlib
@contextlib.contextmanager 上下文管理器
image.png

上下文嵌套:with a as a,b as b:
image.png

你可能感兴趣的:(python 标准库 算法)