>[success] # 对列表进行排列组合 ~~~ 1.permutations 进行排列组合,第一个是排列组合对象,第二个是参与元素数量 2. combinations 无关顺序的 只关心形成数据,两个参数都给填写 ~~~ >[danger] ##### 进行排列 组合 --- permutations ~~~ from itertools import permutations item = ['a', 'b', 'c'] for i in permutations(item): print(i) item = ['a', 'b', 'c'] for i in permutations(item,2): print(i) 打印结果: ('a', 'b', 'c') ('a', 'c', 'b') ('b', 'a', 'c') ('b', 'c', 'a') ('c', 'a', 'b') ('c', 'b', 'a') ('a', 'b') ('a', 'c') ('b', 'a') ('b', 'c') ('c', 'a') ('c', 'b') ~~~ >[danger] ##### 无关顺序的 --- combinations ~~~ from itertools import combinations item = ['a', 'b', 'c'] for i in combinations(item,3): print(i) 打印结果: ('a', 'b', 'c') ~~~