You can download this code by clicking the button below.
This code is now available for download.
This function zips a specified file into a zip format and returns the path of the zipped file.
Technology Stack : zipfile
Code Type : File operation
Code Difficulty : Intermediate
def zip_file(file_path, output_path):
import zipfile
with zipfile.ZipFile(output_path, 'w') as zipf:
zipf.write(file_path)
return f"File '{file_path}' has been zipped to '{output_path}'."