有一个列表,求出列表中重复元素,如 list1 = [1,2,4,3,6,4]
方法一、
list1 = [1,2,4,3,6,4] myset = set(list1) for each in myset: print each,list1.count(each)
方法二、Counter()
list1 = [1,2,4,3,6,4] from collections import Counter c = Counter(list1)