相关疑难解决方法(0)

如何/为什么{frozenset()}中的set()有效?

即使集合不可用,会员检查其他集合工作:

>>> set() in {frozenset()}
True
Run Code Online (Sandbox Code Playgroud)

我期望TypeError: unhashable type: 'set',与Python中的其他行为一致:

>>> set() in {}  # doesn't work when checking in dict
TypeError: unhashable type: 'set'
>>> {} in {frozenset()}  # looking up some other unhashable type doesn't work
TypeError: unhashable type: 'dict'
Run Code Online (Sandbox Code Playgroud)

那么,如何在其他集合中设置成员身份?

python hash set immutability

15
推荐指数
2
解决办法
489
查看次数

标签 统计

hash ×1

immutability ×1

python ×1

set ×1