我有问题,我需要大家的帮助。我阅读 rar 文件(100mb)并处理文本文件(包含在 rarfile 中)。
import glob
import os
import UnRAR2
from os import path, access, R_OK
os.chdir("E:\\sms")
for file in glob.glob("*.rar"):
# extract test.txt to memory
entries = UnRAR2.RarFile(file).read_files('*.txt')
test_content = entries[0][1]
#print test_content
for line in test_content.split("\n"):
A=line.split(' ')
print A[1]
结果:
19009057
7030
9119
9119
....
....
bla...bla...
......
9119
9119
9119
7050
9119
Traceback (most recent call last):
File "E:\LAPTRINH\Android\adt-bundle-windows\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd.py", line 1397, in <module>
debugger.run(setup['file'], None, None)
File "E:\LAPTRINH\Android\adt-bundle-windows\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd.py", line 1090, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File "C:\Users\The\Documents\workspace\unrar\test_unrar.py", line 13, in <module>
print A[1]
IndexError: list index out of range
请帮我!谢谢!!!