Python面试真题-请写出一段Python代码实现删除一个list里面的重复元素?
【Python面试真题】-请写出一段Python代码实现删除一个list里面的重复元素?
1 >>> l = [1,1,2,3,4,5,4] 2 >>> list(set(l)) 3 [1, 2, 3, 4, 5] 4 或者 5 d = {} 6 for x in mylist: 7 d[x] = 1 8 mylist = list(d.keys())
【Python面试真题】-请写出一段Python代码实现删除一个list里面的重复元素?
1 >>> l = [1,1,2,3,4,5,4] 2 >>> list(set(l)) 3 [1, 2, 3, 4, 5] 4 或者 5 d = {} 6 for x in mylist: 7 d[x] = 1 8 mylist = list(d.keys())