How do I open a file for reading and writing that is also truncated to 0?
I\'ve tried:
f = open(PATH, \'w+\')
I\'m unable to read f
If you want to store the data then truncate use r+:
r+
with open(PATH,"r+") as f: line = f.read() f.seek(0) f.truncate()