Skip to content

Instantly share code, notes, and snippets.

@bockor
Created May 15, 2021 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bockor/f62009b002e01812ba98ac868f06079b to your computer and use it in GitHub Desktop.
Save bockor/f62009b002e01812ba98ac868f06079b to your computer and use it in GitHub Desktop.
python zip compression
import zipfile
from datetime import datetime
# create zip file name
zip_file_name = 'myzip_{}.zip'.format(datetime.now().strftime("%d%m%Y"))
# create a ZipFile object and compress
zipObj = zipfile.ZipFile(zip_file_name, 'w', zipfile.ZIP_DEFLATED)
# Add multiple files to the zip
zipObj.write('myfile1')
zipObj.write('myfile2')
# close the Zip File
zipObj.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment