import numpy as np
x = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[10, 11, 12]]
np.savetxt(r'test.txt', x)
保存str格式的
#保存矩阵
np.savetxt("新疾病草药关系sta.txt",contact_ratio, fmt="%s",delimiter=',')
a=np.loadtxt("新疾病草药关系sta.txt", dtype=str,delimiter=',' )