Python模块之 combinations 可迭代对象iterable中选取r个单位进行组合
combinations
作用:
可迭代对象iterable中选取r个单位进行组合
必要操作:
>>> import itertools
帮助查看:
>>> help(itertools)
或 单独查看某个方法(函数)
>>> help(itertools.combinations)
方法(函数):
>>> from itertools import combinations >>> data = [1, 2, 3, 4] >>> result = list(combinations(data , 2)) >>> print(result ) [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]

---
相关文章:
Python安装包下载:https://www.cnblogs.com/wutou/p/17709685.html
Pip 源设置:https://www.cnblogs.com/wutou/p/17531296.html
pip 安装指定版本模块:https://www.cnblogs.com/wutou/p/17716203.html
【汇总】Python模块 - 总目录 https://www.cnblogs.com/wutou/p/15610071.html
<br /><br /><br />
浙公网安备 33010602011771号