青果HA的博客方法一 def count_each_char_1(string): res = {} for i in string: if i not in res: res[i] = 1 else: res[i] += 1 return res print(count_each_char_1('ae...
威廉哥哥的博客# 字母计数 生成一个字典,字母做键,出现的次数做值 def count_alphabet(word): standard = {} for x in range(ord('a'), ord('z') + 1): standard[chr(x)] = 0 # 循环传入的单词 for single_alphabet in ...