2012-07-16 77 views
0

我有一個.rar文件說例如English-Lexicon.rar 在這個.rar文件中,有兩個.txt文件,即neg.txt和pos.txt。我需要使用python訪問neg.txt和pos.txt中的內容。如何才能做到這一點?我對python相當陌生。如何提取文本文件中的信息,在python內的rar文件?

+0

從Python讀取rar文件有點棘手。看到這個答案:http://stackoverflow.com/questions/1185959/read-content-of-rar-file-into-memory-in-python/1186041#1186041 – 2012-07-16 09:43:01

回答

0

還沒有使用過,但google想出了rarfile

+0

我沒有安裝rarfile,但我不知道如何使用這個。而且它也沒有文檔。 – user1452759 2012-07-16 10:18:21

+0

@ user1452759:在首頁上的blurb說:'該接口是儘可能製作成zipfile的.'檢查['Zipfile'文檔](http://docs.python.org/library/zipfile.html) 。 – 2012-07-16 13:04:54

+0

該文檔位於https://rarfile.readthedocs.io/en/latest/api.html。與從文件未壓縮文件直接讀取相比,讀取速度非常慢。 – 2016-05-30 09:09:29