您可以使用 count
:
my_dict = {i:MyList.count(i) for i in MyList}>>> print my_dict #or print(my_dict) in python-3.x{'a': 3, 'c': 3, 'b': 1}或 使用collections.Counter
:
from collections import Countera = dict(Counter(MyList))>>> print a#or print(a) in python-3.x{'a': 3, 'c': 3, 'b': 1}

![Python:计算列表中重复的元素[重复] Python:计算列表中重复的元素[重复]](http://www.mshxw.com/aiimages/31/634214.png)
