擅长:python、mysql、java
<p>您的<code>checkforstamp</code>函数返回非空的已定义字符串:</p>
<pre><code>return 'True'
</code></pre>
<p>因此<code>(not stamp)</code>将始终为false。在</p>
<p>将其更改为返回布尔值,如<code>are_more_tweets</code>所做的:</p>
^{pr2}$
<p>应该没事的。在</p>
<p>有关参考,请参阅<a href="http://docs.python.org/reference/expressions.html#boolean-operations" rel="nofollow">boolean operations</a>文档:</p>
<blockquote>
<p>In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: False, None, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets). <strong>All other values are interpreted as true.</strong></p>
<p>...</p>
<p>The operator <strong>not</strong> yields True if its argument is false, False otherwise.</p>
</blockquote>
<p>编辑:</p>
<p>与<code>if</code>测试中的<code>if</code>相同的问题。由于<code>find('substr')</code>在找不到子字符串时返回<code>-1</code>,因此根据上述规则,如果没有匹配项,<code>str.find('substr')</code>在布尔上下文中将是{<cd9>}。在</p>
<p>这不是代码中出现此问题的唯一地方。请复习你所有的测验。在</p>