I want to create a file object from a file that is inside a zip. I don’t wanna extract that file. Actually I wanna use seek method on a file that is inside a zip. My code:
JavaScript
x
5
1
from zipfile import ZipFile
2
input_zip = ZipFile("xyz.zip")
3
file_name = input_zip.namelist()[0]
4
input_zip.read(name)
5
But I can’t use seek method on it. I wanna make it like this but without extracting the file:
JavaScript
1
3
1
file = open("new.txt", 'rb')
2
file.seek(14)
3
Advertisement
Answer
The documentation says seek
is supported, you just need to open it the right way (as shown there).