Python中的itertools.permutations(关键词:itertools/permutations)
2018-02-25 22:25
375 查看
通俗地讲,就是返回可迭代对象的所有数学全排列方式。
参考文献:
1. Python中itertools模块用法详解 - 脚本之家;
2. itertools.permutations - Python标准库。
Python 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from itertools import permutations >>> permutations(['a', 'b', 'c']) <itertools.permutations object at 0x7ff7b1411890> >>> for item in permutations(['a', 'b', 'c']): ... print item ... ('a', 'b', 'c') ('a', 'c', 'b') ('b', 'a', 'c') ('b', 'c', 'a') ('c', 'a', 'b') ('c', 'b', 'a')
>>> for i in itertools.permutations('123', 2): ... print i ... ('1', '2') ('1', '3') ('2', '1') ('2', '3') ('3', '1') ('3', '2') >>> itertools.permutations('123', 2) <itertools.permutations object at 0x7f5addcca8f0>
参考文献:
1. Python中itertools模块用法详解 - 脚本之家;
2. itertools.permutations - Python标准库。
相关文章推荐
- Python中的itertools.product(关键词:itertools/product)
- Python中的itertools.combinations(iterable, r)(关键词:itertools/combinations)
- 粗谈Python内置库itertools-chain与combinations
- python学习笔记7.6-内建模块itertools
- python模块分析之itertools
- python itertools 模块完全掌握(2)
- Python标准库之循环器(itertools)介绍
- Python模块 - itertools循环器模块
- python itertools的使用
- python itertools.chain 乘号* 实例
- Python itertools 模块
- Python:itertools模块
- PYTHON__ ITERTOOLS模块
- python模块之itertools
- Python中的分组函数(groupby、itertools)
- python itertools
- python中itertools模块介绍---01
- Python标准库13 循环器 (itertools)
- python 内置迭代:itertools
- python,itertools模块