You can download this code by clicking the button below.
This code is now available for download.
Combines the contents of two files and writes the combined content to a new file.
Technology Stack : 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:
data1 = f1.read()
data2 = f2.read()
combined_data = data1 + data2
with open('zipped_file', 'wb') as f:
f.write(combined_data)