#P147-See You Again统计频次
import re
fp=open('..\Stu_pack\See You Again.txt','r')
txt=fp.read()
fp.close()
txt=txt.lower()
txt=re.sub('[,.?:"'!-]','',txt)
words=txt.split()
word_sq={}
for each in words:
if each not in word_sq.keys():
word_sq[each]=1
else:
word_sq[each]=word_sq[each]+1
print(word_sq)
res=sorted(word_sq.items(),key=lambda x:x[1],reverse=True)
print(res)
版权归原作者 莫奈不生花 所有, 如有侵权,请联系我们删除。