Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中创建空集:TypeError:';dict';对象不可调用_Python_Dictionary_Set - Fatal编程技术网

在Python中创建空集:TypeError:';dict';对象不可调用

在Python中创建空集:TypeError:';dict';对象不可调用,python,dictionary,set,Python,Dictionary,Set,我想在Python中创建一个空集 我试过set1=set() 如前所述 但是我得到了一个错误: set1 = set() TypeError: 'dict' object is not callable 如何在Python中创建空集?不幸的是foo=set()是在Python 2和Python 3中声明空集的正确方法 我猜前面几行中有一个set={} 您可以尝试print(type(set))进行检查。您已将dict对象指定给代码中的某个名称set。这就是set()产生该错误的原因。

我想在Python中创建一个空集

我试过
set1=set()
如前所述

但是我得到了一个错误:

set1 = set()
TypeError: 'dict' object is not callable

如何在Python中创建空集?

不幸的是
foo=set()
是在Python 2和Python 3中声明空集的正确方法

我猜前面几行中有一个
set={}


您可以尝试
print(type(set))
进行检查。

您已将
dict
对象指定给代码中的某个名称
set
。这就是
set()
产生该错误的原因。