2017-06-01 199 views
-1

我得到這種類型的錯誤,我不知道是什麼原因造成的。類型錯誤函數不可訂閱

我有這樣的代碼:

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 

回答

4

用途:

print(S(x,T,Y,ñ)) # round parens instead of the square brackets 

調用的函數。

相關問題