擅长:python、mysql、java
<p>看起来你把你的<code>if</code>系列和<code>if</code>-<code>elifs</code>的系列混为一谈。在</p>
<p>请注意:</p>
<pre><code>if cond0:
...
if cond1:
...
else:
bar()
</code></pre>
<p>不等于:</p>
^{pr2}$
<p>如果<code>cond0</code>是{<cd5>},那么前者将调用<code>bar()</code>,而后者则不会。在前者中,它只是一个<code>if</code>,后跟一个完全独立的</em><code>if-else</code>。在</p>
<p>把前者写成这样可能会有帮助:</p>
<pre><code>if cond0:
...
# Note spacing here, emphasizing that the above construct is separate from the one below.
if cond1:
...
else:
bar()
</code></pre>