You can download this code by clicking the button below.
This code is now available for download.
This function compresses two files into a single zip file.
Technology Stack : shutil, zipfile, os
Code Type : File compression
Code Difficulty : Intermediate
def zip_file(file1, file2, output):
import shutil
import zipfile
import os
with zipfile.ZipFile(output, 'w') as zipf:
zipf.write(file1, os.path.basename(file1))
zipf.write(file2, os.path.basename(file2))
return f"Files {file1} and {file2} have been zipped into {output}."