Python Forum

Full Version: Data is deleting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm only starting Python3 and I found a problem. When I want to print something from a file :
print(old_file.read())
I can only do it once, because if I want to repeat this action there is no data in line (empty line)
Maybe I don't understand something, please help me if you can Smile
show your code, in python tags.
After you read the file for first time, your position is at the end of the file. If you try to read again, without closing/opening the file or moving the cursor at the start of the file, there is nothing to read, after the end.
you can read the file in a variable, instead of directly printing the content. then reuse the variable