統計hamlet中出現詞頻最高的10個單詞

先下載好hamlet的英文版本,用python統計書中出現次數最高的單詞 代碼如下: def getText(): #處理特殊字符,把文章單詞全部變成小寫 txt = open(「Hamlet.txt」,「r」).read() txt = txt.lower() for ch in ‘!"#$%&()*+,-./:;<=>[email protected][\]^_‘{|}~’: txt = tx
相關文章
相關標籤/搜索