根据这里提出的问题:Python itertools.combinations: how to obtain the indices of the combined numbers,给定以下代码: importitertools#pairs = [(7, 5), (7, 5), (7, 4), (5, 5), (5, 4), (5, 4)]
indexes = list(iterto
我有一个列表l1,它是我使用itertools.combinations生成的长度为2的所有组合。我打算遍历这些组合,并对它们执行一个操作。为简单起见,此代码仅打印组合a。import itertools
for a in itertools.combinations(l1,2):
print(a) 有没有什么方法可以使组合循环的顺序随机化呢random.shuffle似乎不起作用,因为itertools.combinations没有长度。