擅长:python、mysql、java
<p>为了在Python中实现这一点,我可以这样写(参见<a href="http://docs.python.org/tutorial/errors.html#defining-clean-up-actions" rel="nofollow">Defining cleanup actions</a>):</p>
<pre><code>try:
if ...: return
...
if ...: return
...
finally:
#Code to be executed on every return path (including exceptions) here
</code></pre>