Now I have a task to program: read each line of a txt file which is compressed in a rar file (read directly, not extract the rar file). But I see an unusual problem:
When I print each line of the txt file, it shows only characters of each line. Here are the code:
import rarfile
rf = rarfile.RarFile('C:\\Users\\THELN\\Downloads\\theln.rar')
for f in rf.infolist():
print f.filename, f.file_size
#if f.filename == 'theln.txt':
openf=rf.read(f)
for line in openf:
print line
Here is the result of a line (hello python):
h
e
l
l
o
p
y
t
h
o
n
I've tried to read each line directly in txt file and the code works well. Is there anyone who faces the same problem? Thank you for your help