唠叨荷花

文章
4
资源
0
加入时间
3年2月3天

5.3.2 Counter对象

Counter类提供一个方便和快速统计的工具。例子:#python 3.4import collections cnt = collections.Counter()for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:    cnt[word] += 1print(cnt)结果输出如下:Counter({'blue': 3, 'r