『Collections』常用方法记录
时间:2017-10-22 18:12:06
收藏:0
阅读:215
Counter()方法,
计数器,返回字典,会同时去重,文本处理常用
from collections import Counter
co = Counter(list(‘abcdefgad‘))
co
Out[7]:
Counter({‘a‘: 2, ‘b‘: 1, ‘c‘: 1, ‘d‘: 2, ‘e‘: 1, ‘f‘: 1, ‘g‘: 1})
原文:http://www.cnblogs.com/hellcat/p/7710430.html
评论(0)