擅长:python、mysql、java
<p>您以错误的方式使用了以下代码:</p>
<pre><code> if x in open("C:\\Users\\Chris\\Python\\wordlist.txt"):
</code></pre>
<p>相反,请尝试以下代码,它应该可以解决您的问题:</p>
<pre><code>with open("words.txt", "r") as file:
lines = file.read().splitlines()
for line in lines:
# do something here
</code></pre>