我正在尝试完成列表列表的笛卡尔积。基本元素是元组。关于元组的某些东西似乎真的让人感到困惑。我尝试的产品越多,它就越会增加元组的老鼠嵌套。
这是我的代码product
和我的输出
from itertools import product
listOfListsOfTuples = [ [(1,2),], [(3,4),(5,6)] ]
got = list(product(listOfListsOfTuples))
print('got :',got)
wanted = [ [(1,2),(3,4)], [(1,2),(5,6)] ]
print('wanted:',wanted)
也许我需要回到
got : [([(1, 2)],), ([(3, 4), (5, 6)],)]
wanted: [[(1, 2), (3, 4)], [(1, 2), (5, 6)]]
循环并自己做?
for