统计单词出现的次数

def CountFrequency(word):
    char_dict = {}

    for item in a:
        if item in char_dict:
            char_dict[item] += 1
        else: 
            char_dict[item] = 1
    return char_dict

if __name__ == "__main__":
    a = "success"
    print(CountFrequency(a))

 

posted @ 2023-04-28 16:17  聪明的老李  阅读(3)  评论(0)    收藏  举报