python 統計數組內元素出現次數

def get_counts(sequence): counts={} for x in sequence: if x in counts: counts[x] += 1 else: counts[x] = 1 return counts aa=['a','b','c','d','a','g']
相關文章
相關標籤/搜索