Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python hash() Function

Python hash() Function

Python built-in function Python built-in function


Description

hash() Used to obtain the hash value of an object (a string, number, etc.).

Syntax

hash syntax:


hash(object)

Parameter Description:

Return Value

Returns the hash value of the object.

Example

The following examples demonstrate how to use hash:

hash

(

'

test

'

)

String

2314058222102390712

hash

(

1

)

Digit

1

hash

(

str

(

[

1

,

2

,

3

]

)

)

Union

1335416675971793195

hash

(

str

(

sorted

(

{

'

1

'

:

1

}

)

)

)

Dictionaries

7666464346782421378

Python built-in function Python built-in function