Python f.write() at beginning of file?
- by kristus
I'm doing it like this now, but i want it to write at the beginning of the file instead.
f = open('out.txt', 'a') # or 'w'?
f.write("string 1")
f.write("string 2")
f.write("string 3")
f.close()
so that the contenst of out.txt will be:
string 3
string 2
string 1
and not (like this code does):
string 1
string 2
string 3