更新时间:2023-11-25 22:57:22
这将保留列表和子列表的顺序,并可能在子列表中重复:
this will preserve the order of list and sublists, with possible duplicates in sublists:
y, s = [], set()
for t in x:
w = tuple(sorted(t))
if not w in s:
y.append(t)
s.add(w)
如果
x = [[1,2],[3,4],[5,6],[2,1,1],[2,1],[7,8],[4,3],[1,2,1]]
那么y
将是:
[[1, 2], [3, 4], [5, 6], [2, 1, 1], [7, 8]]