异常处理
try:
# do something
except 异常类型1:
# do something
except 异常类型2:
# do something
...
except:
# do something
finally:
# try正常结束或except异常处理结束都会执行
自定义异常
class MyException(Exception):
def __init__(self,message):
super().__init__(message)
try:
pass
except Exception:
raise MyException('出错辣~')