"Is there a way to create a permutation or product of list of tuples in Python?"

"Is there a way to create a permutation or product of list of tuples in Python?"

lis=[
    (1, 7), (1, 2), (1, 4), (7, 1), (7, 2), (7, 4), (2, 1), (2, 7), (2, 4), (4, 
    1), (4, 7), (4, 2)
]

假设我有上面的元组列表。我想创建所有可能的元组列表,例如 [(1,7,1,2),(1,2,1,4) ...]。结果列表中的每个元组必须是列表中 2 个元组的排列,并且结果列表必须包含所有此类元组。

list(permutations(lis,4)) 给出结果:[((1, 7), (1, 2), (1, 4), (7, 1)), ((1, 7), (1, 2), (1, 4), (7, 2))...]。它正在形成 4 个元组的元组。但我希望内部元组被解包并由 2 个元组的 4 个元素组成,而不是元组的元组。

这是实现它的一种方法:

[a + b for a, b in permutations(lis, 2)]