How to zip a file in python

To zip a file in python you can use the following snippet.

import zipfile
myZip = zipfile.ZipFile('MyArchive.zip','w',zipfile.ZIP_DEFLATED)
myZip.write('Image1.png')
myZip.close()

for more informations see Work with ZIP archives

Please Share us:
Please rate this snippet

One thought on “How to zip a file in python

Leave a Reply