I pull some data from DB and save it to a text file called "databaseoutput.txt". When I run the code below all lines are displayed except the last one - and I know it's there because when I open the file the line that's missing when I run the code below is present
with open("databaseoutput.txt", 'r', encoding='utf-8') as f:
for line in f:
print(line)
What can be causing this?
I just had the same problem as you. When creating my text file I forgot to close it with:
f.close()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.