一个对象当其生命周期内的hash值不发生改变,并且能够跟其余对象进行比较时,这个对象就是Hashtable的。二者Hashtable的对象只有具备相同的hash值时才能判断为相同的对象。html
if __name__ == '__main__': tt = (1,2, (30, 40)) print(hash(tt)) tf = (1, 2, frozenset([30, 40])) print(hash(tf)) tl = (1, 2, [30, 40]) print(hash(tl))
运行的结果以下:python
8027212646858338501htm
-4118419923444501110对象
Traceback (most recent call last):生命周期
File "C:/Users/Administrator/PycharmProjects/collections/abc111.py", line 19, in <module>ip
print(hash(tl))
TypeError: unhashable type: 'list'hash