create empty text file python code example
Example 1: python os make empty file
open(x, 'a').close()
Example 2: how to empty a text file in python
file = open("sample.txt","r+")
file.truncate(0)
file.close()
open(x, 'a').close()
file = open("sample.txt","r+")
file.truncate(0)
file.close()