You can download this code by clicking the button below.
This code is now available for download.
This function is used to unzip a zip file to a specified directory.
Technology Stack : zipfile
Code Type : File operation
Code Difficulty : Intermediate
def zipfile_extract(source, destination):
import zipfile
try:
with zipfile.ZipFile(source, 'r') as zip_ref:
zip_ref.extractall(destination)
except FileNotFoundError:
print("The file was not found.")
except zipfile.BadZipFile:
print("The file is not a zip file or it is corrupted.")