快速统计字符出现次数

快速的统计出字符出现的次数,并以字典显示出来

import pprint

msg = 'It was a bright cold day in April, and the clocks were strikingthirteen'
count = dict()

for i in msg:
    count.setdefault(i, 0)
    count[i] = count[i] + 1

pprint.pprint(count)
原文地址:https://www.cnblogs.com/shiyixirui/p/14673879.html