去重的幾種方式python

a = [1, 2, 3, 2, 4, 1, 5]app # 轉換爲集合,去重 b = set(a) b = list(b) print(b)rem # 遍歷,輸出列表,去重 c = [] for i in a:     if i not in c:         c.append(i) print(c)遍歷 # 字典方法 def removeSame3(L):     myDict = {}
相關文章
相關標籤/搜索