请问:python 在将数据数据保存到.txt 文件时,怎么确定保存的数据格式?谢谢大家!
一、这里我先给出一段代码示例:
import numpy as np
index = np.array([1, 2, 3])
label = np.array([4, 5, 6])
indexs = index.reshape([len(index), 1])
labels = label.reshape([len(label), 1])
result = np.concatenate([labels, indexs], axis=1,)
np.savetxt('test.txt', result, delimiter=" ", fmt='%s')
二、输出文本内容为:

三、而我想要生成的数据文本格式是:

关于 LearnKu
推荐文章: