在Python中生成所有可能的组合

use*_*369 2 python combinations pandas

     Choice1   Choice2   Choice3
A       1         5         9
B       2         6         10
C       3         7         11
D       4         8         12
Run Code Online (Sandbox Code Playgroud)

我如何生成所有可能的组合,包括python中每行的一个选项?

afk*_*ion 5

你可以尝试这个来获得笛卡尔积.

import itertools

rowlists = [[1,5,9],[2,6,10],[3,7,11],[4,8,12]]
for combination in itertools.product(*rowlists):
    print combination
Run Code Online (Sandbox Code Playgroud)