我得到了一个文本文件,上面有一堆数据以及输出散点图的代码,我需要做的是使用文本文件中的变量来计算一个新变量a_mag
,以替换图上给定的v_mag
,但我仍停留在以下几行:
for line in lines:
column = line.split()
starID.append(float(column[0]))
v_mag.append(float(column[1]))
b_v.append(float(column[2]))
parallaxes.append(float(column[3]))
parallax_error.append(float(column[4]))
d.append(float(1/column[3])) # Distance to star
a_mag.append(float(column[1]-(5*math.log10(1/column[3]/10))))
d
和a_mag
是新的变量,d仅用于计算a_mag
,错误代码如下:
22 parallaxes.append(float(column[3]))
23 parallax_error.append(float(column[4]))
---> 24 float(d.append(1/column[3])) # Distance to star
25 a_mag.append(float(Column[1]-(5*math.log10(1/Column[3]/10)))) # Absolute V Magnitude
26
TypeError: unsupported operand type(s) for /: 'int' and 'str'
提前感谢:)
无论出于何种原因,在第24行和第25行中,将float放在每个单独的“column[x]”之前,都可以解决这个问题
相关问题 更多 >
编程相关推荐