【发布时间】:2012-08-18 14:01:09
【问题描述】:
我有一个需要用空格分隔的一维列表。我在 spyder 中运行此脚本,以便在 Mac OS 10.8 上并行运行 ubuntu。
我得到的是这样的:
print poly
Output: [array([ 0.01322341, 0.07460202, 0.00832512])]
print poly[0]
Output: [array([ 0.01322341, 0.07460202, 0.00832512])]
print poly[1]
Output:
Traceback (most recent call last):
File "/home/parallels/.../RampEst.py", line 38, in <module>
print poly[1]
IndexError: list index out of range
“...”是文件目录的其余部分。
我需要的是:
print poly[0]
Output: 0.01322341
print poly[1]
Output: 0.07460202
print poly[2]
Output: 0.00832512
【问题讨论】:
-
您确定您在向我们展示的输出中将括号放在正确的位置吗?
poly和poly[0]打印的内容完全相同,这对我来说似乎很奇怪。 -
另外,您的
array类型是什么?它的输出与标准库中的array.array不匹配(其中包括一个“类型”字符,例如用于双精度浮点数的“d”)。虽然这无关紧要,但如果该类型的接口有问题,则可能会出现问题。 -
你的标题与问题无关。