统计英文文章中词频
2018-04-24 本文已影响0人
lilyindreaming
import re
from collections import Counter
path='E:\etest.txt'
with open(path,'r') as f:
s=f.read()
data=re.split(r'\W+',s)
fdata=Counter(data)
for i,j in fdata.most_common():
print(i,':',j)
import re
from collections import Counter
path='E:\etest.txt'
with open(path,'r') as f:
s=f.read()
data=re.split(r'\W+',s)
fdata=Counter(data)
for i,j in fdata.most_common():
print(i,':',j)