擅长:python、mysql、java
<blockquote>
<p>waht does this line do ? : <code>Exception.__init__(self)</code></p>
</blockquote>
<p><code>ShortInputException(Exception)</code>将您的类<code>ShortInputException</code>声明为<code>Exception</code>的子类。<code>Exception.__init__(self)</code>调用父类的构造函数。在</p>
<p><code>except ShortInputException, x:</code></p>
<p>从<a href="http://docs.python.org/tutorial/errors.html" rel="nofollow">doc</a>:</p>
<blockquote>
<p>When an exception occurs, it may have an associated value, also known as the exception’s argument. The presence and type of the argument depend on the exception type.</p>
<p>The except clause may specify a variable after the exception name (or tuple). The variable is bound to an exception instance with the arguments stored in instance.args.</p>
</blockquote>
<p>在您的示例中,<code>x</code>是引发的异常对象。在</p>