CP学习笔记(8) - try: except 语句
try:
<try suite> # always excecute
except <exception class> as <name>: # <exception class> can be subclass of Exception Class
<except suite> # excecuted when excecuting <try suite> meets errors
栗子
>>> try:
x = 1/0
except ZeroDivisionError as e:
print('handling a', type(e))
x = 0
handling a <class 'ZeroDivisionError'>
>>> x
0