方法一: file = open("test.txt", 'w').close() 直接清空“test.txt”里面的内容 方法二: with open("test.txt", 'r+') as file: file.truncate(0) 相关文章: