Python 将元组传递给冻结集
我有这个Python 将元组传递给冻结集,python,Python,我有这个元组 t = ( { "path": "/api/", "uuid": "068aebae", "params": { "name": "foobar", }, "response": {"is_true&qu
元组
t = (
{
"path": "/api/",
"uuid": "068aebae",
"params": {
"name": "foobar",
},
"response": {"is_true": False},
"content": "bar",
},
)
我想传给一个frozenset
>>> frozenset(d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'
>frozenset(d)
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
TypeError:无法损坏的类型:“dict”
我该怎么做?您的元组包含一个字典。字典是,这意味着包含它们的元组也是。如果要将字典(以及内部字典)用作集合元素的一部分,则需要将其更改为元组或其他可散列的内容。你可能会对它感兴趣。