【发布时间】:2017-10-24 16:27:33
【问题描述】:
我想将几个值(浮点数和整数)和数组保存到一个文本文件中。我尝试使用 astropy 表和ascii.write(),但出现值错误。
ValueError: 列表初始化中的元素必须是 Column 或类似列表的
代码:
from astropy.table import Table
from astropy.io import ascii
table = Table([x, y, propNum, inc], names=('x', 'y', 'propNum', 'inc'))
ascii.write(table, 'test4.dat')
输入:
x = [6512905, 6291646, 3667192, -358003, -4246455, -6512905, -6291646, -3667192, 358003, 4246455]
y = [-1739743, 2420707, 5656530, 6731751, 5235671, 1739743, -2420707, -5656530, -6731751, -5235671]
propNum = 100
inc = 51.762
期望的输出:
6512905, -1739743, 100, 51.762
6291646, 2420707
3667192, 5656530
... ...
【问题讨论】:
-
你不能把
propNum和inc的值重复N次吗?
标签: python python-2.7 file numpy astropy