from collections import Counter a = [1, 2, 3, 1, 1, 2] result = Counter(a) print result
输出:
{1: 3, 2: 2, 3: 1}