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())