AttributeError 调用不存在的方法引发的异常。
EOFError 遇到文件末尾引发的异常。
ImportError 导入模块出错引发的异常。
IndexError 列表越界引发的异常。
IOError I/O操作引发的异常,如打开文件出错等。
KeyError 使用字典中不存在的关键字引发的异常。
NameError 使用不存在的变量名引发的异常。
TabError 语句块缩进不正确引发的异常。
ValueError 搜索列表中不存在的值引发的异常。
ZeroDivisionError 除数为零引发的异常。
2.语法
try:
...guarded clause...
except ...exPRession... :
...exception handler codee...
finally:
...clean-up code...
3. raise语句
def crossProduct(seq1, seq2):
if not seq1 and not seq2:
raise ValueError, "Sequence arguments must be non-empty."
return [(x, y) for x1 in seq1 for x2 in seq2]
Copyright © 2019- ysem.cn 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务