Compress Two Files into a Zip Archive

  • Share this:

Code introduction


Compresses two files into a single zip file.


Technology Stack : zipfile

Code Type : File processing

Code Difficulty : Intermediate


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