file = open("write_test.txt", encoding="utf-8",mode="w")
file.write("君臣佐使")
file.close()
with open("write_test.txt", encoding="utf-8",mode="a") as data:
data.write("神农本草经")
w模式是重写(原文件的内容删除),a模式是追加(原文件的内容保留)。