You can download this code by clicking the button below.
This code is now available for download.
Add a specified file to a ZIP file.
Technology Stack : zipfile, os
Code Type : File processing
Code Difficulty : Intermediate
def zipfiles(file1, file2):
import zipfile
import os
with zipfile.ZipFile(file1, 'w') as zipf:
zipf.write(file2, os.path.basename(file2))
return f'File {file2} has been added to {file1}'