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