In [11]: a Out[11]: frozenset({(2, -2), (2, -1), (3, -2), (3, -1)}) In [12]: b Out[12]: frozenset({(4, -2), (4, -1), (5, -2), (5, -1)}) In [13]: hash(a) Out[13]: 665780563440688 In [14]: hash(b) Out[14]: 665780563440688
从Python文档:
hash(object) -> integer
Return a hash value for the object. Two objects with the same value have
the same hash value. The reverse is not necessarily true, but likely.
最简单的例子是数字-1和-2,它们在python中具有相同的哈希码:
>>> print(hash(-1)) -2 >>> print(hash(-2)) -2