python collections模块

collections

from collections import Counter
Counter([1,2,2,2,2,3,3,3,4,4,4,4])

输出字典

Counter({1: 5, 2: 3, 3: 2})

--- 她说, 她是仙,她不是神
原文地址:https://www.cnblogs.com/bregman/p/5707127.html