Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> var = 12
>>> hash(var)
12
>>> var = '12'
>>> hash(var)
2881029940170453192
>>>
>>> var=12.0
>>> hash(var)
12
>>> var = (0,1,2)
>>> hash(var)
1267305975155491464
>>>
>>> var = [0,1,2]
>>> hash(var)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
hash(var)
TypeError: unhashable type: 'list'
>>>
>>> var = set(2,3,4)
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
var = set(2,3,4)
TypeError: set expected at most 1 arguments, got 3
>>> var = set([2,3,4])
>>> var
{2, 3, 4}
>>> hash(var)
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
hash(var)
TypeError: unhashable type: 'set'
>>> var = {0,1,2}
>>> hash(var)
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
hash(var)
TypeError: unhashable type: 'set'
>>>
>>> var = {0:999,1:888}
>>> var
{0: 999, 1: 888}
>>> hash(var)
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
hash(var)
TypeError: unhashable type: 'dict'
>>>
>>> var="abc"
>>> hash(var)
-9146920486740483374
>>>
>>>
Python内置函数hash()
最新推荐文章于 2024-05-23 10:38:34 发布