实例10:文本词频统计分析
统计哈姆雷特中词频为前十的单词:def getText(): txt=open("hamlet.txt","r").read() txt=txt.lower() for ch in '!"#$%&()*+,-./:;<=>?@[\\]^_‘{\}~': txt=txt.replace(ch,"") return txth...