Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data is deleting
#1
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
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Deleting data in SQlite3 SmukasPlays 0 1,461 Jul-25-2020, 02:07 PM
Last Post: SmukasPlays
  Deleting data in sqlite3 JJ39 3 2,496 Jun-23-2019, 04:39 PM
Last Post: noisefloor

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020