统计字符串中每个字符出现的次数(Python)

#统计字符串中每个字符出现的次数 以The quick brown fox jumps over the lazy dog为例

message='The quick brown fox jumps over the lazy dog'
count={}
for character in message:
    count.setdefault(character,0)
    count[character]=count[character]+1

print(count)

参考:《Python编程快速上手--》

posted @ 2018-09-09 21:29  一去二三浪里小白龙  阅读(10583)  评论(0编辑  收藏  举报
//增加一段JS脚本,为目录生成使用