2017-01-30 64 views
-3

我正在使用Python進行項目工作。我是一名初學者,當我運行該程序時出現此錯誤。TypeError:'float'對象在Python中沒有屬性'__getitem__'

Traceback (most recent call last): 
    File "E:/Python/1616/checkProfile.py", line 104, in <module> 
    p.getResults() 
    File "E:\Python\1616\Profile.py", line 67, in getResults 
    for i in range(2): self._s[1] += e.getS[1] 
TypeError: 'float' object has no attribute '__getitem__' 


Error in Line 67 

http://pastebin.com/HXvppfmU

+1

請上傳您的代碼 –

+3

這意味着您正在嘗試在浮動上使用'[]',這沒有任何意義。我會猜測'self._s'是一個浮點數?儘管沒有更多上下文的代碼,但無法肯定地說。 – Carcigenicate

+0

您正嘗試在float數據類型上調用get方法,該方法由於float數據類型沒有get方法而不起作用。 – AdjunctProfessorFalcon

回答

0

檢查什麼是允許的數據類型的方法,

dir(datatype) 
# As for float, try dir(float) 
#This will suggest you that there is no method called __getitem__ for float. 
# You might be trying to get some data or you are using []/()/{} which is not correct. 

嘗試發佈我們的代碼。

相關問題