You can download this code by clicking the button below.
This code is now available for download.
This function takes a file path and an output path, using the built-in zipfile library to compress the specified file and save it to the specified output path.
Technology Stack : zipfile library
Code Type : File compression
Code Difficulty : Intermediate
def zip_file(file_path, output_path):
import zipfile
with zipfile.ZipFile(output_path, 'w') as zipf:
zipf.write(file_path)