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 file.
Technology Stack : File operation, binary read and write
Code Type : File operation
Code Difficulty : Intermediate
def zip_file(file1, file2, output):
import shutil
with open(file1, 'rb') as f1, open(file2, 'rb') as f2, open(output, 'wb') as output_file:
shutil.copyfileobj(f1, output_file)
shutil.copyfileobj(f2, output_file)