2012-07-16 78 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