import zipfile
fantasy_zip = zipfile.ZipFile('E:\\Shared\\DOWNLOADED\\c.zip')
fantasy_zip.extractall('E:\\Shared\\DOWNLOADED\\extract)
fantasy_zip.close()
我的密码是“你好” 如何包含要提取的密码?
最佳答案
Python zipfile
包可以解压有密码的文件。
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())
在你的情况下,
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())
关于python - 使用python提取zip文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50714467/