AttributeError:'NoneType'对象没有属性'endswith'

mr.*_*r.G 11 python attributeerror nonetype ends-with

我目前正在开发一个更新网页的Python脚本.但是运行主脚本会产生以下错误:

<res status='-1'><error message="'NoneType' object has no attribute 'endswith'"><![CDATA[
Traceback (most recent call last):
  File "/path/to/file/ws_config.py", line XXXX, in Run
    tests = TestList().tests
  File "/path/to/file/ws_config.py", line XXXX, in __init__
    UpdateTestGroup(None),
  File "/path/to/file/ws_config.py", line XXXX, in __init__
    test = CT.CurlTest(settings),
  File "/path/to/file/config_tests.py", line XXXX, in __init__
    self.params.path = os.path.join('/', os.path.join(params.dir, params.file))
  File "/usr/lib/python2.6/posixpath.py", line 67, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'
Run Code Online (Sandbox Code Playgroud)

我不能通过任何代码,因为太长了.我想要了解的是错误的位置或代码的哪一部分触发了AttributeError.你能帮我么???

zha*_*gyu 7

pathelif是一个NoneNone == ''返回False,因此仍然会被执行.而倒退,params.dir是一个None.你需要检查你params.dir生成的代码,看看它是怎么None来的.