import re
from collections import Counter
txt = open("D:/a1.txt").read()
new_txt = re.split('\W+', txt)
result = Counter(new_txt)
a = result.most_common(10)
print(a)
python3统计词频程序,可用。
import re
from collections import Counter
txt = open("D:/a1.txt").read()
new_txt = re.split('\W+', txt)
result = Counter(new_txt)
a = result.most_common(10)
print(a)
python3统计词频程序,可用。