sql去除重复,Python 去除序列s中的重复元素

1.在可hash的情况下使用set,时间复杂度为 O(n)return list(set(s)) 2.不可hash,但支持比较使用sort,时间复杂度为 O(nlogn)t=list(s) try: t.sort() except TypeError: del t else: return [x for i,x in enumerate(t) if not i or t[i]!=t[i-1]] 3... [阅读全文]
1 共1条 分1页