擅长:python、mysql、java
<p>只是另外一个提示:</p>
<p>在python中,您不需要对空字符串执行相等测试。请改为使用<a href="https://docs.python.org/2/library/stdtypes.html#truth-value-testing" rel="nofollow">truth value testing</a>。那更像是Python。</p>
<pre><code>if not coinN:
</code></pre>
<p>真值测试包括以下测试:</p>
<ul>
<li>无</li>
<li>假</li>
<li>任何数字类型的零,例如0、0L、0.0、0j</li>
<li>任何空序列,例如,,,,[]。</li>
<li>任何空映射,例如{}。</li>
<li>用户定义类的实例,如果该类定义了<strong>非零</strong>或<strong>len</strong>方法,则当该方法返回整数零或bool值False时。<a href="https://docs.python.org/2/library/stdtypes.html#truth-value-testing" rel="nofollow">1</a></li>
</ul>
<p>示例:</p>
<pre><code>>>> s = ''
>>> if not s:
... print 's is empty'
...
s is empty
>>>
</code></pre>