擅长:python、mysql、java
<p>听起来您想要<code>or</code>,而不是嵌套的<code>if</code>语句。您测试的所有条件永远不可能同时为真,因此嵌套的<code>if</code>(在本文中类似于<code>and</code>)永远不会全部通过,让您的代码打印<code>True</code>。在</p>
<p>尝试:</p>
<pre><code>if ((oneScore == "positive" and twoScore > 0) or
(oneScore == "null" and twoScore == 0) or
(oneScore == "neutral" and twoScore == 0) or
(oneScore == "negative" and twoScore < 0)):
print bookID, ID, oneScore, twoScore, "TRUE"
</code></pre>
<p>在<code>twoScore</code>从文件中读取的行之后,<code>twoScore</code>的比较仍然会有问题,因为它将是一个字符串。在进行比较之前,您需要在某个时刻调用<code>int</code>。在</p>