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