擅长:python、mysql、java
<p>来自<a href="https://docs.python.org/3/tutorial/errors.html#handling-exceptions" rel="noreferrer">Python Documentation</a>:</p>
<blockquote>
<p>An except clause may name multiple exceptions as a parenthesized tuple, for example</p>
</blockquote>
<pre><code>except (IDontLikeYouException, YouAreBeingMeanException) as e:
pass
</code></pre>
<p>或者,仅对于Python 2:</p>
<pre><code>except (IDontLikeYouException, YouAreBeingMeanException), e:
pass
</code></pre>
<p>在Python2.6和2.7中,用逗号将异常与变量分隔仍然有效,但现在已被弃用,在Python3中不起作用;现在应该使用<code>as</code>。</p>