【发布时间】:2014-09-17 03:23:39
【问题描述】:
我正在尝试制作一个返回给定高度温度的插值代码
def Fdrag(y):
alt = [a1, a2, a3,....,an]
temp = [t1, t2, t3,...., tn]
for i in range(len(alt)):
if alt[i] < y < alt[i+1]:
temp = temp[i] + (y - y[i])*(temp[i+1]-temp[i])/(alt[i+1] - alt[i])
return temp
我不断收到此错误:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
Fdrag(10)
File "C:/Users//Desktop/interp_test.py", line 6, in Fdrag
temp = temp[i] + (y - y[i])*(temp[i+1]-temp[i])/(alt[i+1] - alt[i])
TypeError: 'int' object is not subscriptable
【问题讨论】:
标签: python list int interpolation