You can download this code by clicking the button below.
This code is now available for download.
This function compresses a file at the specified path into a zip format and saves it to the specified output path.
Technology Stack : os, zipfile
Code Type : File compression
Code Difficulty : Intermediate
def zip_file(file_path, output_path):
import os
import zipfile
with zipfile.ZipFile(output_path, 'w') as zipf:
zipf.write(file_path, os.path.basename(file_path))
return True