python 错误集锦 2017/02/04

来源:互联网 发布:mac最好的下载工具 编辑:程序博客网 时间:2024/05/22 04:41

<1>local variable '***' referenced before assignment

      变量使用前未定义

  函数中的某一变量被赋值后会被认为是局部变量,当在函数外被调用时 会出现如此错误

解决方法:在变量前添加 global ***



<2> ‘NoneType’ object has no attribute to '***'

    实例:next_scene_name = current_scene.enter()

    原因:所有到的类并没有加载进来

<3>‘builtin_function_or_method object has no attribute to '***'

  实例:print Death.quips[randint(0,len(self.quips)-1)]

 

 内置函数或方法对象没有获取项目属性

 例如 range(1,5) 写成 range[1,5]



0 0