一.一些常见的异常
1.AssertionError
断言语句失败
>>> assert 1
>>> assert0
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
assert0
NameError: name 'assert0' is not defined
2.AttributeError
尝试访问位置的对象属性
>>> list1=[]
>>> list1.posd
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
list1.posd
AttributeError: 'list' object has no attribute 'posd'
3.IndexError
索引值超出序列的范围
>>> list2=[1,2,3]
>>> list2[3]
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
list2[3]
IndexError: list ind