python 错误集
来源:互联网 发布:yy淘宝兼职刷信誉 编辑:程序博客网 时间:2024/06/06 16:56
TypeError: ‘str’ object is not callable
原因是str()方法被调用时,发现代码中定义过一个叫str的变量,覆盖了str方法。
# str = 'Hello World!'# print str,type(str)
解决方法:将变量注释或rename
IOError: [Errno 2] No such file or directory: ‘aaa.txt’
file = open('aaa.txt')
原因路径错误,找不到文件
ImportError: No module named A
import A
导入模块错误,没有该模块
IndexError: list index out of range
list1 = [1,2,3]print list1[3]
索引错误,list索引超出范围
KeyError: ‘height’
KeyError:字典中不存在的键
dict1 = {'name':'ivy','age':20,'gender':'female'}print dict1['height']
NameError: name ‘a’ is not defined
NameError:访问没有定义的变量
print a
IndentationError: expected an indented block
IndentationError:缩进错误
if 1==1:print 'aaa'
SyntaxError: invalid syntax
SyntaxError:语法错误
list2 = [1,2,3,4】
TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’
TypeError:不同类型间的无效操作
print 1+'1'
int和字符之间拼接不能用+号
ZeroDivisionError: integer division or modulo by zero
ZeroDivisionError:除数为0
print 5/0
0 0
- [错误集]Python语法错误
- python 错误集
- python 错误集
- python正则表达式错误集
- Python错误
- python错误
- python错误
- python错误
- Python错误
- 【Python】Python错误类型03
- Python错误和异常
- python maxlength错误
- python doctest 错误
- python socket错误描述
- Python 转码错误
- python 错误类型总结
- Python编码错误处理
- python错误记录
- maven Setting文件
- Nginx+Tomcat实现负载均衡
- 【LEET-CODE】34. Search for a Range【Medium】
- bootstrap-table的使用与条件搜索
- Linux修改防火墙开放端口
- python 错误集
- J2EE系列之Struts2学习笔记(十八)--Struts2国际化
- Android的版本更新
- AppCompat does not support the current theme features
- **张鸿洋**封装的okhttputils 上传文字加图片 实现发表朋友圈效果
- ubuntu添加或删除PPA
- 搜索练习1/棋盘问题 dfs详解
- nginx做转发时,带'_'的header内容丢失
- 浅谈C++与C的一些不同