p
y
t
h
o
n
寫
x
文
件
python寫txt檔案
python寫txt檔案
with open("train_info.txt", "a", encoding="utf-8") as f:
f.write("loss:"+str(total_loss)+"\n") # 如果檔案存在,新寫入内容會覆寫掉原内容,一定要注意!!!
f.write("acc:"+str(correct/(len(train_loader)*batchsize))+"\n") # 如果檔案存在,新寫入内容會覆寫掉原内容,一定要注意!!!