擅长:python、mysql、java
<pre><code>f = open('file.txt')
lines = f.readlines()
f.close()
</code></pre>
<p><code>lines</code>就是你想要的</p>
<p>其他选择:</p>
<pre><code>f = open( "file.txt", "r" )
lines = []
for line in f:
lines.append(line)
f.close()
</code></pre>
<p>更多阅读:</p>
<p><a href="https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files" rel="nofollow">https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files</a></p>