摘要: >>> from collections import defaultdict>>> s='mmississippi'>>> d=defaultdict(int)>>> for i in s: d[i]+=1 >>> print dict(d){'i': 4, 'p': 2, 's': 4, 'm': 2}官方文档解释:class collections.defaultdict([default_factory[, ...]] 阅读全文
posted @ 2013-10-29 23:05 LisPythoniC 阅读(452) 评论(0) 推荐(0) 编辑