I'm confused and don't know what to do about this. I'm trying to overwrite the files text.
Asked
Active
Viewed 153 times
-2
-
just open file with w flag? – YOU Jul 04 '16 at 10:08
-
1Please consider providing some code of what you have tried so far. – Ian Jul 04 '16 at 10:09
-
6Try this. http://stackoverflow.com/questions/4914277/how-to-empty-a-file-using-python – umar faraz Jul 04 '16 at 10:09
1 Answers
0
when opening a file with 'w'
flag, it will rewrite the file if it exists.
with open('yourfile.ext', 'wt') as fileObj:
fileObj.write(stuff)

kmaork
- 5,722
- 2
- 23
- 40