众所周知,list去掉重复元素可将list转为set即可,
but,
>>> test = [1,2,'a','a'] >>> test1= list(set(test)) >>> print(test1) [1, 2, 'a'] >>> test.append(['a']) >>> print(test) [1, 2, 'a', 'a', ['a']] >>> test2= list(set(test)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list' >>>