from collections import Counter a = [1, 2, 3, 1, 1, 2] result = Counter(a) print result
输出:
{1: 3, 2: 2, 3: 1}
from collections import Counter a = [1, 2, 3, 1, 1, 2] result = Counter(a) print result
输出:
{1: 3, 2: 2, 3: 1}
转载于:https://www.cnblogs.com/demo-deng/p/10173525.html