Adding File to Zip Archive

  • Share this:

Code introduction


Add a specified file to a zip archive.


Technology Stack : zipfile

Code Type : File operation

Code Difficulty : Intermediate


                
                    
def zip_file(arg1, arg2):
    import zipfile
    with zipfile.ZipFile(arg1, 'w') as zipf:
        zipf.write(arg2, arcname=arg2)
    return zipf                
              
Tags: