PYTHON - basic question
Hello,
why the following code is not working as i expect it to : Code:
The output is : Here should be the output from the file - Here should be the output from the STR- BLAH in other words print "". in_file.read() doesn't seem to work. I wonder why? |
you have to import sys, not just argv from sys.
Code:
import sys |
Quote:
|
I'm not sure what you expect to see. You read one line from the file and assign it to STR. You then read the next line from the file and print it out. The output shows that the first line read from the file (and assigned to STR) is "BlAH" and the next line read from the file is empty.
|
Quote:
But i think I understand what you meant - i read the file into variable str and the pointer (or whatever it's called in python) is @ the end of the file. So when i read the file again - i get 0 bytes. ekhh silly me. Thank you for the tip! AZ |
Quote:
Ref: http://docs.python.org/2/library/std...l#file-objects |
All times are GMT -5. The time now is 05:05 PM. |