Compress Two Files into a ZIP File

  • Share this:

Code introduction


Compress two files into one ZIP file.


Technology Stack : zipfile

Code Type : File operation

Code Difficulty : Intermediate


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