itertools模块
1、permutations:排列,考虑顺序
>>> from itertools import permutations
>>> rc=permutations(['a','b','c'],3)
>>> list(rc)
[('a', 'b', 'c'), ('a', 'c', 'b'), ('b', 'a', 'c'), ('b', 'c', 'a'), ('c', 'a', 'b'), ('c', 'b', 'a')]
2、combinations:组合,不考虑顺序
>>> rc=combinations(['a','b','c'],3)
>>> list(rc)
[('a', 'b', 'c')]
3、product:笛卡尔积
>>> from itertools import product
>>> lis=['abc','123']
>>> from itertools import product
>>> rc=product(*lis) # 相当于rc=product('abc','123')
>>> list(rc)
[('a', '1'), ('a', '2'), ('a', '3'), ('b', '1'), ('b', '2'), ('b', '3'), ('c', '1'), ('c', '2'), ('c', '3')]