I have this zip file structure.
zipfile name = filename.zip
filename> images>
style.css
default.js
index.html
I want to update just index.html
. I tried to update index.html
, but then it contains only index.html
file in 1.zip file and other files are removed.
This is the code which I tried:
import zipfile
msg = 'This data did not exist in a file before being added to the ZIP file'
zf = zipfile.ZipFile('1.zip',
mode='w',
)
try:
zf.writestr('index.html', msg)
finally:
zf.close()
print zf.read('index.html')
So how can I update only index.html
file using Python?