数字,字符串,元组,是固定的,所以可以hash 列表,字典都是可变的,所以不能hash In [234]: hash(1) Out[234]: 1 In [235]: hash(23) Out[235]: 23 In [236]: hash('caimengzhi') Out[236]: -41402223196077605 In [237]: hash('caimengzhi') Out[237]: -41402223196077605 In [238]: hash([1,2,3]) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-238-fb5b1b1d9906> in <module>() ----> 1 hash([1,2,3]) TypeError: unhashable type: 'list' In [239]: hash({name:'cmz'}) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-239-d9962f34fa76> in <module>() ----> 1 hash({name:'cmz'}) TypeError: unhashable type: 'dict'