numpy保存数组到txt
with open('backbone_feature.txt', 'a') as f4:
np.savetxt(f4, im23, delimiter='\t', newline='\n')
f4.close()
其中delimiter=’\t’代表每个数字之间用空格分隔;newline=’\n’代表最后接上换行符。
如果使用
with open('pscore.txt', 'a') as f3:
print(str(pscore[best_pscore_id]), file=f3)
来保存numpy数组,会在txt文件中增加[],即以数组的样式保存数字。