Create ZIP File with Specified Content

  • Share this:

Code introduction


Create a ZIP file and add a specified file to it.


Technology Stack : zipfile, os

Code Type : File operation

Code Difficulty : Intermediate


                
                    
def zipfile_create(arg1, arg2):
    import zipfile
    import os

    with zipfile.ZipFile(arg1, 'w') as zipf:
        zipf.write(arg2, os.path.basename(arg2))                
              
Tags: