1使用内置函数
lists = [1,1,2,3,4,6,6,2,2,9]
lists = list(set(lists))
2 unique函数
import numpy as np
lists = [1,1,2,3,4,6,9,6,2,2]
lists = np.unique(lists)
3 del函数
lists = [1,1,2,3,4,6,9,6,2,2]
lists.sort()
t = lists[-1]
for i in range(len(lists)-2,-1,-1):
# print(i)
if t == lists[i]:
# del lists[i]
lists.remove(lists[i])
else:
t = lists[i]
网友评论