You can download this code by clicking the button below.
This code is now available for download.
This function creates a zip file containing the input file path. It first uses the `zipfile` module to create a new zip file and then adds the input file to the zip file. Finally, it creates a new zip file and adds the same input file again.
Technology Stack : Built-in library: zipfile
Code Type : Function
Code Difficulty : Intermediate
def zip_file(file_path, output_path):
import zipfile
with zipfile.ZipFile(file_path, 'w') as zipf:
zipf.write(file_path, arcname=file_path)
with zipfile.ZipFile(output_path, 'w') as zipf:
zipf.write(file_path, arcname=file_path)