Example of what I am trying to achieve:
My text file (test1.txt
) contains following two line:
John scored 80 in english
tim scored 75 in english
I have compressed this file to test1.zip
and I am trying to read the contents with following code:
f = 'test1.zip'
z = zipfile.ZipFile(f, "r")
zinfo = z.namelist()
for name in zinfo:
with z.open(name) as f1:
fi1 = f1.readlines()
for line in fi1:
print(line)
But the result I am getting is
b'John scored 80 in english\r\n'
b'tim scored 75 in english\r\n'
How can I read the contents of this zip file which should give me same output as original file content that is:
John scored 80 in english
tim scored 75 in english