You can download this code by clicking the button below.
This code is now available for download.
This function uses the zipfile module to create a ZIP file and adds the specified file to the ZIP file.
Technology Stack : zipfile, os
Code Type : File operation
Code Difficulty : Intermediate
def zipfile(arg1, arg2):
import zipfile
import os
with zipfile.ZipFile(arg1, 'w') as zipf:
zipf.write(arg2, os.path.basename(arg2))
return zipfile.ZipFile(arg1, 'r')