Why do I get AttributeError: 'NoneType' object has no attribute 'something'?

前端 未结 10 2014
长情又很酷
长情又很酷 2020-11-21 13:36

I keep getting an error that says

AttributeError: \'NoneType\' object has no attribute \'something\'
10条回答
  •  渐次进展
    2020-11-21 13:50

    g.d.d.c. is right, but adding a very frequent example:

    You might call this function in a recursive form. In that case, you might end up at null pointer or NoneType. In that case, you can get this error. So before accessing an attribute of that parameter check if it's not NoneType.

提交回复
热议问题