列表python递归排列列表

时间:2015-03-04 23:37:11

标签: python recursion permutation nested-lists

如何以特定方式操作字符串列表以便

lst = [ [a, b], [c, d, e], [f, a, e] ]
# turns into
lst = [ [a, b], [b, a], [c, d, e], [c, e, d], [d, c, e],etc...]
#there are 14 combinations

1 个答案:

答案 0 :(得分:2)

from itertools import *

combo_list = []

for i in your_list:
    for j in permutations(i, len(i)):
        combo_list.append(j)
相关问题