# 将矩阵以不同方式存储为txt,文件,尝试一遍就知道其中的不同
import numpy as np
#生成数据2*3的0矩阵
x = y = z = np.ones((2, 3))
print(x)
# 保存数据
#参数的意思:将要保存的路径和新生成的文件,文件名,数据存储格式,分隔符
np.savetxt(r'H:\WorkSpaces\python\medicine\test\2\test.txt', x)
np.savetxt(r'H:\WorkSpaces\python\medicine\test\2\test1.txt',
x, fmt='%d', delimiter=',')
np.savetxt(r'H:\WorkSpaces\python\medicine\test\2\test2.txt', x, delimiter=',')
#行以什么分隔
np.savetxt(r'H:\WorkSpaces\python\medicine\test\2\test3.txt', x, newline='a')
np.savetxt(r'H:\WorkSpaces\python\medicine\test\2\test4.txt',
x, delimiter=',', newline='a')
#加头
np.savetxt(r'H:\WorkSpaces\python\medicine\test\2\test5.txt',
x, delimiter=',', header='abc')
#加尾巴
np.savetxt(r'H:\WorkSpaces\python\medicine\test\2\test6.txt',
x, delimiter=',', footer='abc')
print(np.loadtxt(r'H:\WorkSpaces\python\medicine\test\2\test1.txt', delimiter=','))
np.loadtxt(r'H:\WorkSpaces\python\medicine\test\2\test2.txt', delimiter=',')
print("finished")