Python:如何从中的列表中获取所有有序选项

Python:如何从中的列表中获取所有有序选项,python,iteration,Python,Iteration,我有以下方法 a = [1, 11, 111] b = [2, 22, 222] c = [3, 33, 333] list_of_lists = [a, b, c] lists_with_the_i_elements = [0 for x in range(len(list_of_lists))] for i in range(0, len(list_of_lists)): lists_with_the_i_elements[i] = [list_i[i] for list_i in

我有以下方法

a = [1, 11, 111]
b = [2, 22, 222]
c = [3, 33, 333]
list_of_lists = [a, b, c]
lists_with_the_i_elements = [0 for x in range(len(list_of_lists))]
for i in range(0, len(list_of_lists)):
    lists_with_the_i_elements[i] = [list_i[i] for list_i in list_of_lists]
result = list(itertools.product(lists_with_the_i_elements[0],lists_with_the_i_elements[1],lists_with_the_i_elements[2]))
print(result)
雷乌斯尔特:

[(1, 11, 111),
(1, 11, 222), 
(1, 11, 333), 
(1, 22, 111), 
(1, 22, 222), 
(1, 22, 333), 
(1, 33, 111), 
(1, 33, 222), 
(1, 33, 333), 
(2, 11, 111), 
(2, 11, 222), 
(2, 11, 333),
(2, 22, 111), 
(2, 22, 222), 
(2, 22, 333), 
(2, 33, 111), 
(2, 33, 222), 
(2, 33, 333),
(3, 11, 111),
(3, 11, 222),
(3, 11, 333),
(3, 22, 111), 
(3, 22, 222), 
(3, 22, 333), 
(3, 33, 111), 
(3, 33, 222), 
(3, 33, 333)]
预期结果是:

[1,2,3]
[1,22,3]
[1,222,3]
[1,2,33]
[1,22,33]
[1,222,33]
[1,2,333]
[1,22,333]
[1,222,333]
[11,2,3]
[11,22,3]
[11,222,3]
[11,2,33]
[11,22,33]
[11,222,33]
[11,2,333]
[11,22,333]
[11,222,333]
...
我想要一个函数,当它接收到
list\u of\u list
时,它将返回以下输出: 因此,我希望有一个函数,它将为我提供所有列表组合,当值索引对应于输入中的列表索引时,这些组合是从输入中的每个列表中选择的成员

另一个简单的例子:

def combo(*args):
     #do something
...
combo([1],[2],[3])
===>[1,2,3]
combo([1],[2],[3,33])
===>[1,2,3],[1,2,33]

我查看了
itertools
中的所有选项,但没有找到任何解决方案。

类似的内容应该可以帮助您:

list(itertools.product([1,11,111], [2, 22, 222], [3, 33, 333]))

类似的内容应该可以帮助您:

list(itertools.product([1,11,111], [2, 22, 222], [3, 33, 333]))

还有12,112,113我修正了这个问题,它错了…我弄糊涂了你到目前为止尝试了什么?还有12,112,113我修正了这个问题,它错了…我弄糊涂了你到目前为止尝试了什么?嗯。。没有,还不清楚。举个例子吧?看,我浏览了itertools和随机谷歌搜索-我可以实现我自己,但我寻找“pythonic”的方法“python”的方法只是使用标准库。告诉我为什么
itertools.product
不符合您的目的。。没有,还不清楚。举个例子吧?看,我浏览了itertools和随机谷歌搜索-我可以实现我自己,但我寻找“pythonic”的方法“python”的方法只是使用标准库。请告诉我为什么
itertools.product
不能满足您的需要