利用set和list去除重复值

xiaoxiao2022-06-11  100

list:有序可重复

set:无序不可重复

list.index(x):返回x在list中的下标

sorted(x,cmp=None,key=None):cmp=>比较规则,key=>权值

def delRe(listA): return sorted(set(listA), key = listA.index) a=[1,3,6,6,6,7,7,8,8] print(delRe(a))

 

转载请注明原文地址: https://www.6miu.com/read-4932154.html

最新回复(0)