假设我要排列如下的列表
可以看出有2*2*2=8中组合方式用了product这个工具
a=[[0,1],[1,1],[2,1]]
from itertools import product
for i in product(*a):
print(i)
b=[i for i in product(*a)]
print(b)
product(iter1,iter2, ... iterN, [repeat=1]);创建一个迭代器,生成表示item1,item2等中的项目的笛卡尔积的元组,repeat是一个关键字参数,指定重复生成序列的次数
product(range(2), repeat=3) #--> 000 001 010 011 100 101 110 111
常用的排列组合,需要记录下