C.E*_*mes 4 python zip file extract zipfile
import zipfile
fantasy_zip = zipfile.ZipFile('E:\\Shared\\DOWNLOADED\\c.zip')
fantasy_zip.extractall('E:\\Shared\\DOWNLOADED\\extract)
fantasy_zip.close()
Run Code Online (Sandbox Code Playgroud)
我的密码是“你好”我如何包含要提取的密码?
Pythonzipfile包可以解压有密码的文件。
def unzip_folder(zip_folder, destination, pwd):
"""
Args:
zip_folder (string): zip folder to be unzipped
destination (string): path of destination folder
pwd(string): zip folder password
"""
with zipfile.ZipFile(zip_folder) as zf:
zf.extractall(
destination, pwd=pwd.encode())
Run Code Online (Sandbox Code Playgroud)
在你的情况下,
import zipfile
zip_folder = 'E:\\Shared\\DOWNLOADED\\c.zip'
destination = 'E:\\Shared\\DOWNLOADED'
pwd = '<YOUR_PASSWORD>'
with zipfile.ZipFile(zip_folder) as zf:
zf.extractall(
destination, pwd=pwd.encode())
Run Code Online (Sandbox Code Playgroud)