May-19-2018, 10:17 PM
f.read('hello world')It's just
f.read()
.The point of using
with open()
is that the file will be closed automatically.So trow away all
close()
with open('bacon.txt', 'w') as f: f.write('hello world') with open('bacon.txt') as f: print(f.read())
Output:hello world