使用np.savetxt将数组另存为列 [英] Saving arrays as columns with np.savetxt

查看:288
本文介绍了使用np.savetxt将数组另存为列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一些可能非常简单的事情.我想使用'np.savetxt'将三个数组作为列保存到文件中

I am trying to do something that is probable very simple. I would like to save three arrays to a file as columns using 'np.savetxt' When I try this

x = [1,2,3,4]
y = [5,6,7,8]
z = [9,10,11,12]

np.savetxt('myfile.txt', (x,y,z), fmt='%.18g', delimiter=' ', newline=os.linesep)

像这样保存数组

1 2 3 4
5 6 7 8
9 10 11 12

但是我想这样的是

1 5 9
2 6 10
3 7 11
4 8 12

推荐答案

使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆