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 at a specified path to a specified directory.
Technology Stack : Packages and technologies used in the code[English]
Code Type : Function
Code Difficulty : Intermediate
def zipfile_extract(file_path, extract_to_dir):
"""
解压指定路径的zip文件到指定目录。
"""
import zipfile
import os
with zipfile.ZipFile(file_path, 'r') as zip_ref:
zip_ref.extractall(extract_to_dir)
print(f"Extracted files to {extract_to_dir}")