Python 3.x 如何从python 3中的集合中获取列表

Python 3.x 如何从python 3中的集合中获取列表,python-3.x,Python 3.x,这似乎在Python2.7中有效,但在Python3中无效。在Python3中,有没有一种简单的方法来创建我所缺少的集合列表?提前谢谢 mylist = [1,2,3,4,5] list(set(mylist)) #Traceback (most recent call last): # File "<stdin>", line 1, in <module> #TypeError: 'list' object is not callable mylis

这似乎在Python2.7中有效,但在Python3中无效。在Python3中,有没有一种简单的方法来创建我所缺少的集合列表?提前谢谢

    mylist = [1,2,3,4,5]
    list(set(mylist))
#Traceback (most recent call last):
#  File "<stdin>", line 1, in <module>
#TypeError: 'list' object is not callable
mylist=[1,2,3,4,5]
列表(集合(mylist))
#回溯(最近一次呼叫最后一次):
#文件“”,第1行,在
#TypeError:“列表”对象不可调用

很抱歉,如果以前有人问过这个问题,我做了一个快速搜索,没有看到特定于python3的答案

列表(set(…)
工作正常。该错误表示代码的3.x版本有一个名为
list
set
的变量,隐藏了内置函数。也许您将
mylist
重命名为
list
?请放心,这个错误会在Python 2中引发完全相同的错误消息。

Geesh,你完全正确。对不起,我是一片雪花。我会删除这个。