We can read all the files without extracting zip file easily. and we can read line by line in zip files.
Script
try:
root = zipfile.ZipFile("C:\Python27\Project\Rokar.zip", "r")
except:
root = "."
data=[]
for name in root.namelist()
for line in root.read(name):
data.append(line)
print ''.join(data)
or
try:
root = zipfile.ZipFile("C:\Python27\Project\Rokar.zip", "r")
except:
root = "."
with root as z:
with z.open('manage.py') as f:
for line in f:
print line
No comments:
Post a Comment