List 在列表中调用元组中的元素,并不断得到一个Unsubscribable类型错误

List 在列表中调用元组中的元素,并不断得到一个Unsubscribable类型错误,list,python-2.7,tuples,element,List,Python 2.7,Tuples,Element,Python 2 这就是正在发生的事情 >>> highscores= [('A',7),('B',8),('C',3),('D',2)] >>> highscores[0][1] Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> highscores[0][1] TypeError: 'int' object is uns

Python 2

这就是正在发生的事情

>>> highscores= [('A',7),('B',8),('C',3),('D',2)]
>>> highscores[0][1]

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    highscores[0][1]
TypeError: 'int' object is unsubscriptable
高分=[('A',7),('B',8),('C',3),('D',2)] >>>高分[0][1] 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 高分[0][1] TypeError:“int”对象不可订阅
我对编程非常陌生,我不知道为什么会发生这种情况。什么是pyshell,你为什么要使用它?它似乎在对你的翻译做一些非常古怪的事情

>>> highscores= [('A',7),('B',8),('C',3),('D',2)]
>>> highscores[0][1]

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    highscores[0][1]
TypeError: 'int' object is unsubscriptable
在codepad.org上签出您的代码,它可以正常工作:


IMHO,刚开始的时候,不要使用任何“助手”,比如pyshell、eclipse、iPython等等。它们会比你意识到的更频繁地妨碍你。当然,YMMV。

我得到了高分[0][1]=>
7
,在那次作业之前还有其他背景吗?