-1

如何创建具有独特元素的列表本身的笛卡尔积?

例如,lists = ['a', 'b', 'c'],我想创建[['a', 'b'], ['a','c'], ['b','c']].

4

1 回答 1

1
from itertools import combinations
lists = ['a', 'b', 'c']
print(list(map(list, combinations(lists,2))))
于 2021-02-04T01:23:31.073 回答