python itertools

葫芦的运维日志

浏览量 5550 2018/09/10 18:00

>>> import itertools
>>> iter=itertools.permutations([1,2,3])
>>> iter
<itertools.permutations object at 0x0000000002209780>
>>> list(iter)
[(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]
>>>
>>>
>>> dir(itertools)
['__doc__', '__name__', '__package__', 'chain', 'combinations', 'combinations_with_replacement', 'compress', 'count', 'cycle', 'dropwhile', 'groupby',
 'ifilter', 'ifilterfalse', 'imap', 'islice', 'izip', 'izip_longest', 'permutations', 'product', 'repeat', 'starmap', 'takewhile', 'tee']
>>>

 

📝 版权声明

本文作者:王梓 | 原文链接:https://www.bthlt.com/note/7-itertools

出处:葫芦的运维日志 | 转载请注明出处并保留原文链接

打赏

留言板

留言提交后需管理员审核通过才会显示

© 冰糖葫芦甜(bthlt.com) 2025 王梓打赏联系方式陕ICP备17005322号-1