#文件路径 file="D:\\a.txt" file_path=open(file,"a+") print("好好学习",file=file_path) #关闭流 file_path.close()
file="D:\\b.txt" with open(file,"a+") as file: file.write("好好学习")