Python hash() Function

Python 内置函数Python Built-in Functions


Description

hash()Used to obtain the hash value of an object (such as strings or numbers).

Syntax

hash syntax:

hash(object)

Parameter description:

  • object -- object;

Return Value

Returns the hash value of the object.

Examples

The following example demonstrates the usage of hash:

>>>hash('test') # string 2314058222102390712 >>> hash(1) # number 1 >>> hash(str([1,2,3])) # set 1335416675971793195 >>> hash(str(sorted({'1':1}))) # dictionary 7666464346782421378 >>>

Python 内置函数Python Built-in Functions

Other Extensions