返回列表或字符串等中字符出现次数的字典:
>>> import collections
>>> a = 'ddsdsdsdsf'
>>> collections.Counter(a)
Counter({'d': 5, 's': 4, 'f': 1})
>>> a = [1,1,2,2,0]
>>> collections.Counter(a)
Counter({1: 2, 2: 2, 0: 1})
返回列表或字符串等中字符出现次数的字典:
>>> import collections
>>> a = 'ddsdsdsdsf'
>>> collections.Counter(a)
Counter({'d': 5, 's': 4, 'f': 1})
>>> a = [1,1,2,2,0]
>>> collections.Counter(a)
Counter({1: 2, 2: 2, 0: 1})