How to empty a file using Python
Opening a file creates it and (unless append ('a') is set) overwrites it with emptyness, such as this:
open(filename, 'w').close()
Alternate form of the answer by @rumpel
with open(filename, 'w'): pass
Opening a file creates it and (unless append ('a') is set) overwrites it with emptyness, such as this:
open(filename, 'w').close()
Alternate form of the answer by @rumpel
with open(filename, 'w'): pass