照着人家视频上写的pythone,解压压缩包没用。代码如下
import itertools
import zipfile
filename = "1.zip"
def uncompress(filename,password):
try:
with zipfile.ZipFile(filename) as zfile:
zfile.extractall("./",pwd=password.encode("utf-8"))
return True
except:
return False
chars = "1234567890"
for c in itertools.permutations(chars,4):
password = "".join(c)
print(password)
result = uncompress(filename,password)
if not result:
print("解压失败",password)
else:
print("解压成功",password)
break
在用winrar对文件加密压缩为zip时,设置密码时需勾选zip传统加密,用上述方法可以实现解压。
如对你有帮助,请采纳。点击我回答右上角【采纳】按钮。