小编use*_*504的帖子

Python'set'对象不支持索引

我正在使用Python(3.2.2)shell中的Windows 7操作系统.试图学习我输入的语言并返回以下内容:

>>> cast = {
    'cleese',
    'Palin',
    'Jones',
    'Idle'
    }
>>> print (cast[1])
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    print (cast[1])
TypeError: 'set' object does not support indexing
>>> cast.append('Gilliam')
Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    cast.append('Gilliam')
AttributeError: 'set' object has no attribute 'append'
Run Code Online (Sandbox Code Playgroud)

==========================

似乎问题不在编码中,而在于程序的安装方式.

我已经安装,卸载并再次安装,但是resutl是相同的.在Python的shell准备好使用之前,我需要做些什么吗?

汉斯

indexing append typeerror

8
推荐指数
1
解决办法
5万
查看次数

标签 统计

append ×1

indexing ×1

typeerror ×1