Compress Two Files into a Single Zip

  • Share this:

Code introduction


This function compresses two files into a single zip file.


Technology Stack : zipfile, shutil

Code Type : File compression

Code Difficulty : Intermediate


                
                    
def zip_file(file1, file2, output):
    import shutil
    with zipfile.ZipFile(output, 'w') as zipf:
        zipf.write(file1, arcname=file1)
        zipf.write(file2, arcname=file2)                
              
Tags: