快速的统计出字符出现的次数,并以字典显示出来
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)