Python 23 Programming Tutorial - How to Read and Write Files

I read in the comments that a lot of people were having trouble

fw = open('sample.txt', 'w')
fw.write('Writing some stuff in my text file\n')
fw.write('I like bacon\n')
fw.close()

fr = open('sample.txt', 'r')
text = fr.read()
print(text)
fr.close()

你可能感兴趣的:(Python 23 Programming Tutorial - How to Read and Write Files)