You can download this code by clicking the button below.
This code is now available for download.
Compress two files into a single zip file.
Technology Stack : os, zipfile
Code Type : File processing
Code Difficulty : Intermediate
def zip_file(file1, file2):
import os
import zipfile
def create_zip_file(zip_path, files):
with zipfile.ZipFile(zip_path, 'w') as zipf:
for file in files:
zipf.write(file, os.path.basename(file))
zip_path = 'combined.zip'
create_zip_file(zip_path, [file1, file2])
return zip_path