我在这里和那里看过许多类似的帖子,但似乎没有一个能解决我的问题。我有一个搜索文件路径的方法:def getDumpFile(self):
self.saveDump()
dumpname = str(self.filename)+'-01.netxml'
filepath = os.path.join('/some/path/to/file',dumpname)
try:
if os.path.exists(os.path.join('/some/path/to/file',dumpname)):
logging.debug( "Filepath "+str(filepath) )
return filepath
else:
logging.debug( "File Not Found" )
return None
except OSError as e:
logging.debug( "File not created: "+str(e) )
return None
在main函数中,我把这个函数称为:
^{pr2}$
当我执行上述代码时,它会在getDumpFile()方法中找到正确的路径,但服务器发出异常:Unexpected exception in wireless.views.attackAP with type and error 'str' object is not callable
我真的不知道为什么将filepath传递给xmlfile变量(我相信它以前从未启动过)会导致错误,请帮助。谢谢。在
编辑:实际上是代码xmlfile = wscanner.getDumpFile()发出错误,但我不知道原因。注释掉这一行可以消除错误,但是我以后需要这个路径。在