//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()