以下是这两天在敲Python代码时遇到的错误,在这里简单做一个小结——
1、AttributeError:'Other' object has no attribute 'altered'
Other类中没有定义altered方法,后面还调用了altered方法
AttributeError: ‘module’ object has no attribute’xxx’
没有成功调用模块,检查from…import…
2、ImportError:No module named setuptools
在首次安装软件包时可能出现,需要安装setuptools
命令行输入:python setup.py install
3、IndentationError 缩进错误
1)IndentationError:unindent does not match any outer indentation level
缩进混用了空格和Tab,可通过视图→显示空格和制表符查看
4、TypeError:‘NoneType’ object is not iterable
空对象不可迭代
去找找你所调用的函数的返回的值的类型,是否和返回值所赋值的变量的类型,两者是否匹配。
5、UnboundLocalError: local variable 'xxx' referenced b
本地变量xxx引用前没定义。