目录
问题描述:
方案一 (常见的写法):
方案二:
问题描述:
如下图所示,欲将下图内容写入一个.txt

方案一 (常见的写法):
使用f.write()函数, 如果记事本想要换行,需要换行符"\n"
write_file = "/home/qtxu/test/test2.txt"
with open(write_file, "a") as f:
f.write("========================================"+"\n")
f.write("fold: {} Best Model Measure".format(0)+"\n")
f.write("========================================")
方案二:
解锁新写法, file=f, 无须换行符,会自动换行
write_file = "/home/qtxu/test/test.txt"
with open(write_file, "a") as f:
print("========================================", file=f)
print("fold: {} Best Model Measure".format(0), file=f)
print("========================================", file=f)















![【C++】重载运算符+-=>/*[]==++-- MyString 智能指针(* ->)](https://img-blog.csdnimg.cn/71604cfea51243ed9fb573052c90645c.png)



