Created
May 15, 2021 07:10
-
-
Save bockor/f62009b002e01812ba98ac868f06079b to your computer and use it in GitHub Desktop.
python zip compression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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