csv文件添加文件内容和读取

append content to file

import numpy as np 
acc_list=np.array([0.97,0.92,0.93,0.89])
# 注意这个地方添加文件不需要特别声明是什么文件
file = open("result.csv", "a+")
print("{:.2f}, {:.2f}".format(acc_list.mean(), acc_list.std()), file=file)
print("{:.2f}, {:.2f}".format(1.2323, 2.233424), file=file)
file.close()

read data from file

import pandas as pd 

data = pd.read_csv("./result.csv",header=None)
data

csv文件添加文件内容和读取_第1张图片

import pandas as pd 

data = pd.read_csv("./result.csv",header=0)
data

你可能感兴趣的:(学习)