Python usuń zawartość pliku
f = open('file.txt', 'r+')
f.truncate(0)
Horrible Hornet
f = open('file.txt', 'r+')
f.truncate(0)
fileVariable = open('textDocName.txt', 'r+')
fileVariable.truncate(0)
fileVariable.close()
#one way is to open the file for writing
file = open("sample.txt","w")
file.close()
#another way
file = open("example.txt","r+")
file.truncate(0)
file.close()
open('file.txt', 'w').close()