gpt4 book ai didi

python - 属性错误: 'str' object has no attribute 'extractall' extracting zip from brute force

转载 作者:行者123 更新时间:2023-12-01 02:10:21 24 4
gpt4 key购买 nike

不确定为什么会收到以下错误,我之前暴力破解后知道密码,但不允许我提取文件。

需要将我的文件解压到目录/tmp

那么我是否遗漏了任何明显的东西?

输出错误:

Traceback (most recent call last):
File "/tmp/usercode.py", line 45, in <module>
myZip.extractall("/tmp",pwd = str(password))
AttributeError: 'str' object has no attribute 'extractall'

代码:

import zipfile
from zipfile import ZipFile
import zipfile

zf = zipfile.ZipFile('/tmp/myfile.zip')
for x in range(0,139):
#Legacy for loop now
password = "past"
print(password)
for filename in [ 'textinhere.txt' ]:
myZip = "textinhere.txt"
try:
myZip.extractall("/tmp",pwd = str(password))
except KeyError:
print 'ERROR: Did not find %s in zip file' % filename
else:
print filename, ':'
print repr(data)

最佳答案

您在这里定义一个字符串:myZip = "textinhere.txt"

exctractallZipFile 类的方法。因此,您需要首先构造一个 ZipFile 实例,假设该名称是您希望用作 ZipFile 实例路径的文件:

myZip = ZipFile("textinhere.txt")

...只有这样你才能调用 myZip.extractall(...

关于python - 属性错误: 'str' object has no attribute 'extractall' extracting zip from brute force,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48738220/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com