如果m为二维及以下np数组,则可直接使用np.savetxt()方法进行保存
import numpy as np
#result为一个二维数组
result = np.array([1,2,3],[5,6,3])
# 写入文件
np.savetxt("result1.txt",result);
# 读取文件
dataset = np.loadtxt('result1.txt')
如果m为三维及以上np数组,则需要使用np.save()进行保存
import numpy as np
# 创建数组(3维)
a = np.arange(100).reshape((10, 5, 2))
# 存储
np.save(file="data.npy", arr=a)
# 读取
b= np.load(file="data.npy")