You can download this code by clicking the button below.
This code is now available for download.
Compresses two files into a single zip file.
Technology Stack : os, zipfile
Code Type : Function
Code Difficulty : Intermediate
def zip_file(file1, file2):
import os
import zipfile
base_name = os.path.splitext(file1)[0]
zip_name = base_name + '.zip'
with zipfile.ZipFile(zip_name, 'w') as zipf:
zipf.write(file1)
zipf.write(file2)
return zip_name