python delete all data within txt code example Example: python delete all data from file file = open("sample.txt","r+") file.truncate(0) file.close()