You can download this code by clicking the button below.
This code is now available for download.
Merge the contents of two files into one file and save it as a ZIP file.
Technology Stack : Built-in library
Code Type : File operation
Code Difficulty : Intermediate
def zip_file(file1, file2):
with open(file1, 'rb') as f1, open(file2, 'rb') as f2:
combined = f1.read() + f2.read()
with open('zipped_file.zip', 'wb') as output:
output.write(combined)