一般来说,可以使用
itertools.product
. 你需要转换你的输入
zip(*l)
In [8]: import itertools
In [9]: l = [[1, 1, 1],
...: ['A', 'B', 'C'],
...: ['D', 'E', 'F']]
In [10]: list(itertools.product(*zip(*l)))
Out[10]:
[(1, 1, 1),
(1, 1, 'C'),
(1, 1, 'F'),
(1, 'B', 1),
(1, 'B', 'C'),
(1, 'B', 'F'),
(1, 'E', 1),
(1, 'E', 'C'),
(1, 'E', 'F'),
('A', 1, 1),