Python'set'对象不支持索引

use*_*504 8 indexing append typeerror

我正在使用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准备好使用之前,我需要做些什么吗?

汉斯

Dan*_*her 19

Python似乎运行正常.关键是set不支持索引或追加.请尝试使用列表([]而不是{}).代替附加,setadd,但索引已经出来.

Python有很多帮助,

>>> help(set)
Run Code Online (Sandbox Code Playgroud)

打印了很多关于sets 的信息.