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})
posted @ 2016-07-26 13:14  bregman  阅读(155)  评论(0)    收藏  举报