read file problem
Fuzzyman
fuzzyman at gmail.com
Mon Feb 6 11:08:27 EST 2006
Ernesto wrote:
> I'm just want to read in the contents of a (text) file. The text file
> is filled with semiColon delimited floating point strings...
>
> 0.456;1.265;99.742;...
>
> For some reason, I can't get the contents back when I call file.read()
> Here's my code.
>
> filePath = "C:\\folder\\myFile.txt
> fileHandle = open(filePath, 'r').read();
> print fileHandle.read()
>
> # This prints nothing when it should print the above values.... Thanks
> for the help
Try adding a 'print fileHandle' in there...
That line should be :
fileHandle = open(filePath, 'r')
The '.read()' part returns the full file... so further reads have no
effect.
All the best,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
More information about the Python-list
mailing list