everyone. When I am trying to print out the content of the file, I found that if I don't close the file after writing it, I can't read the content and print it out, can anyone explain to me what's happening? Also, is there any alternative way to accomplish that?
wf = open('text.txt','w')
wf.write("HI\nThis is your testing txt file\n!!!")
rf = open('text.txt', 'r')
print(rf.read())
wf.close()
rf.close()