On 25/10/2012 19:15, myles broomes wrote:

I'm trying to code a program that retrieves data from a seperate file but 
according to my program, the seperate file is empty when I know it clearly 
isn't. It's a txt file and here are its contents: 120
74
57
44
12
I thought that maybe the problem was the code I had written but even when I try 
and read from the file in an interactive session in the Python Shell, it does 
the same thing. I open it in read mode and assign to a variable like so: 
scoresFile=open('highScores.txt','r') But whenever I try to say read from it: 
scoresFile.read() It comes up with a blank string: ' ' Can anyone help me?  
Myles Broomes                                  


Works fine for me.

c:\Users\Mark\MyPython>type highScores.txt
120
74
57
44
12
c:\Users\Mark\MyPython>type mytest.py
from __future__ import print_function, division
scoresFile=open('highScores.txt','r')
print(scoresFile.read())
c:\Users\Mark\MyPython>py -3 mytest.py
120
74
57
44
12

So unless you show us exactly what you've tried we'll find it difficult if not impossible to diagnose your problem.

--
Cheers.

Mark Lawrence.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to