You can download this code by clicking the button below.
This code is now available for download.
This function merges the contents of two files into a new ZIP file.
Technology Stack : Built-in libraries: built-in file operations
Code Type : File operation
Code Difficulty : Intermediate
def zip_file(file1, file2):
with open(file1, 'rb') as f1, open(file2, 'rb') as f2:
with open(file1 + '.zip', 'wb') as f3:
f3.write(f1.read())
f3.write(f2.read())