📅  最后修改于: 2022-03-11 14:48:28.236000             🧑  作者: Mango
import os
filename="file.txt"
answ=os.path.exists(filename)
with open(filename, "a" if answ else "w") as f:
if(answ):
f.write("\n")
f.write("hi!")