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

One thought on “How to zip a file in python”

Leave a Reply