擅长:python、mysql、java
<p>你可以利用<code>readlines</code></p>
<pre><code>with open('testfile', 'r') as file:
# read a list of lines into data
lines = file.readlines()
with open('testfile', 'w') as file:
for line in lines:
# do your checks on the line..
file.write(line.strip() + ' checked' )
print('done')
</code></pre>