像这种有什么优雅的处理方法?
try..except ? 但是错误异常太多了(像这个 exc.DataError,其他的还有 OptionError ),一个个 except ?
1
dawncold 2017-09-21 20:43:46 +08:00 1
The base exception class is SQLAlchemyError. Exceptions which are raised as a result of DBAPI exceptions are all subclasses of DBAPIError.
|
2
cevincheung OP @dawncold #1
from sqlalchemy.exc import DBAPIError, SQLAlchemyError try: # code except DBAPIError: print('dbapi') except SQLAlchemyError: print('sqlalchemy') 然而并没有什么事情发生 |