.readlines() shouldn't return an array?
<p>I have a problem with <code>.readlines()</code>.
it used to only return the line specified, i.e. if I ran</p>

<pre><code>f1 = open('C:\file.txt','r')
filedata = f1.readlines(2)
f1.close()
print filedata
</code></pre>

<p>it should print the second line of <strong>file.txt.</strong>
However now when I run that same code, it returns the entire contents of the file in an array, with each line in the file as a separate object in the array. I am using the same PC and am running the same version of <code>python (2.7).</code></p>

<p>Does anyone know of a way to fix this?</p>

<p>Change this:</p>

<pre><code>f1.readlines(2)
</code></pre>

<p>To this:</p>

<pre><code>f1.readlines()[2]
</code></pre>

python readlines