python列表去重代码
a = [[1,2],[3,4],[4,3],[2,1],[5,6],[5,7],[7,6],[7,5]]
def demo(a):
b = [set(x) for x in a]
c = []
for i in range(len(b)):
temp1 = b[i]
if all((i == len(b)-1, temp1 not in c)):
c.append(temp1)
else:
for j in range(i+1,len(b)):
temp2 = b[j]
if temp1 == temp2:
if temp1 in c:
pass
else:
c.append(temp1)
else:
if temp1 not in c:
c.append(temp1)
return c
demo(a)
原创文章,转载请注明出处:http://124.221.219.47/article/py_list_unique/