Zip File Extraction Function

  • Share this:

Code introduction


This function accepts a path to a zip file and a target extraction directory, and extracts the contents of the zip file to the specified directory.


Technology Stack : zipfile

Code Type : File operation

Code Difficulty : Intermediate


                
                    
def zipfile_extract(file_path, extract_to_dir):
    """
    解压zip文件到指定目录
    """
    import zipfile
    with zipfile.ZipFile(file_path, 'r') as zip_ref:
        zip_ref.extractall(extract_to_dir)                
              
Tags: