python清空文件内容

text_path="/xxx/xxx"
def clear():
with open(text_path, 'w') as f1:
f1.seek(0)
f1.truncate()
print("清空数据")

clear()

posted @ 2020-06-18 15:07  ls0202  阅读(9112)  评论(0编辑  收藏  举报