📜  计算文件中单词的频率 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:54.230000             🧑  作者: Mango

代码示例1
from collections import Counter
def word_count(fname):
        with open(fname) as f:
                return Counter(f.read().split())

print("Number of words in the file :",word_count("test.txt"))