#统计字符串中每个字符出现的次数 以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编程快速上手--》

相关文章:

  • 2021-09-02
  • 2021-07-14
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
猜你喜欢
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案