Python 属性错误:';str';对象没有属性';拔取全部';从蛮力中提取拉链
我不知道为什么我会得到以下错误,我知道密码后,蛮力迫使它早些时候,但不会让我提取文件 需要将我的文件解压缩到/tmp目录 那么我是否遗漏了任何明显的东西 输出错误:Python 属性错误:';str';对象没有属性';拔取全部';从蛮力中提取拉链,python,zip,zipfile,brute-force,Python,Zip,Zipfile,Brute Force,我不知道为什么我会得到以下错误,我知道密码后,蛮力迫使它早些时候,但不会让我提取文件 需要将我的文件解压缩到/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
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'
您正在此处定义一个字符串:
myZip=“textinhere.txt”
extractall
是ZipFile
类的一种方法。因此,您需要首先构造一个ZipFile
的实例,假设此名称是您希望用作ZipFile实例路径的文件:
myZip=ZipFile(“textinhere.txt”)
…只有这样,您才能调用
myZip.extractall(…
啊,是的,当我知道文件在目录A中时,不知何故找不到该文件?请提供该文件的绝对路径,以确保指向正确的位置
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)