<human>:  How to erase the file contents of text file in Python?
<bot>: Here is some code to erase the contents of a file `filename`

open('filename', 'w').close()

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.