在python中使用多个异常

在python中使用多个异常,python,exception,python-3.x,exception-handling,Python,Exception,Python 3.x,Exception Handling,有没有办法在python中使用多个异常?类似下面的代码: try: #mycode except AttributeError TypeError ValueError: #my exception 我的意思是如何相互使用AttributeErrorTypeErrorValueError?使用元组: try: # mycode except (AttributeError, TypeError, ValueError): # catches any of the thr

有没有办法在python中使用多个异常?类似下面的代码:

try:
   #mycode
except AttributeError TypeError ValueError:
   #my exception
我的意思是如何相互使用
AttributeError
TypeError
ValueError

使用元组:

try:
   # mycode
except (AttributeError, TypeError, ValueError):
   # catches any of the three exception types above
引述:

try
套件中发生异常时,将开始搜索异常处理程序。此搜索将依次检查except子句,直到找到与异常匹配的子句。
[…]
对于带有表达式的except子句,将计算该表达式,如果生成的对象与异常“兼容”,则该子句将与异常匹配。如果对象是异常对象的类或基类,或包含与异常兼容的项的元组,则该对象与异常兼容

我的