You can download this code by clicking the button below.
This code is now available for download.
This function compresses the contents of two files into a single zip file.
Technology Stack : zipfile
Code Type : File processing
Code Difficulty : Intermediate
def zipfiles(file1, file2):
with open(file1, 'rb') as f1, open(file2, 'rb') as f2:
z = zipfile.ZipFile('zipped_files.zip', 'w')
z.writestr('file1', f1.read())
z.writestr('file2', f2.read())
z.close()