我遇到了这种错误,我不知道是什么原因导致的。
我有这段代码:
def S(x,T,Y,ñ):
u = 3
return u
T = [0,1,2,3,4,5]
Y = [0,1,2,3,4,5]
x = 0.5
z = 0
for ñ in range(len(T)-1):
if T[ñ]<=x and x<T[ñ+1]:
print("correct: " + str(ñ))
print(S[x,T,Y,ñ])
然后它说:
TypeError Traceback (most recent call last)
<ipython-input-16-98eb96968499> in <module>()
10 if T[ñ]<=x and x<T[ñ+1]:
11 print("correct: " + str(ñ))
---> 12 print(S[x,T,Y,ñ])
TypeError: 'function' object is not subscriptable
答案 0 :(得分:4)
使用:
print(S(x,T,Y,ñ)) # round parens instead of the square brackets
调用该函数。