IOError 文件读写异常
ValueError值异常,一般是数据类型不对应
IndexError下标索引越界
2.try...except...
try:
f=open(‘test.txt‘)
except IOError as e:
print(e)
>>:
[Errno 2] No such file or directory: ‘test.txt‘
3.错误基类Exception
try:
print(a)
except Exception as e:
print(e)
>>:
name ‘a‘ is not defined
原文:http://blog.51cto.com/13803166/2130055