擅长:python、mysql、java
<p>你的代码应该解释清楚并且易于阅读。<a href="http://www.python.org/dev/peps/pep-0008/" rel="nofollow noreferrer">Style Guide for Python</a>给出了一个有助于回答您的问题的示例:</p>
<blockquote>
<p>Use ''.startswith() and ''.endswith()
instead of string slicing to check for
prefixes or suffixes.</p>
<p>startswith() and endswith() are
cleaner and less error prone. For</p>
<p>example:</p>
<pre><code> Yes: if foo.startswith('bar'):
No: if foo[:3] == 'bar':
</code></pre>
</blockquote>