简体   繁体   中英

TypeError: 'float' object has no attribute '__getitem__' in Python

I am working on a project in Python. I am a beginner and I am getting this error when I am running the program.

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

to check what are the methods allowed for datatypes,

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. 

Try to post ur code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM