擅长:python、mysql、java
<ol>
<li><p>您想读取文件,但正在以写模式打开文件。您应该使用<code>r</code>,而不是<code>w+</code></p></li>
<li><p>对文件进行迭代的最简单方法是在file对象上直接进行<code>for</code>循环迭代</p></li>
<li><p>不是错误而是吹毛求疵。您不关闭文件。您可以用<code>with.. as</code>上下文管理器来解决这个问题</p></li>
</ol>
<hr/>
<pre><code>uinput = input("input here: ")
with open("save.txt", "r") as f:
for line in f:
if uinput in line:
print('Match found')
</code></pre>