w3resource
w3resource logo

Python: hash() function

(追記) (追記ここまで)
(追記) (追記ここまで)

hash() function

The hash() function returns the hash value of the object (if it has one).

Hash values are integers. They are used to quickly compare dictionary keys during a dictionary lookup. Numeric values that compare equal have the same hash value (even if they are of different types, as is the case for 1 and 1.0).

Version:

(Python 3.2.5)

Syntax:

hash(object)

Parameter:

Name Description Required /
Optional
object An object. Required.

Example: Python hash() function

# hash for integer unchanged
print('Hash for 252 is:', hash(252))
# hash for decimal
print('Hash for 252.25 is:',hash(252.25))
# hash for string
print('Hash for Python is:', hash('Python Example'))

Output:

Hash for 252 is: 252
Hash for 252.25 is: 576460752303423740
Hash for Python is: 4427590093227766552

Python Code Editor:

[フレーム]

PREV : globals()
NEXT : help()

Test your Python skills with w3resource's quiz



Follow us on Facebook and Twitter for latest update.

(追記) (追記ここまで)


(追記) (追記ここまで)
(追記) (追記ここまで)


AltStyle によって変換されたページ (->オリジナル) /