Detailed introduction to Python's built-in hash function

高洛峰
Release: 2017-03-21 10:52:26
Original
2524 people have browsed it

English document:

##hash<a href="http://www.php.cn/wiki/739.html" target="_blank"></a>(object)Return 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) .

Instructions:  

1. Return the hash value of

object, using integer express. Hash values ​​can be used to quickly compare key values ​​during dictionary lookups.

>>> hash('good good study')
1032709256
Copy after login
 2. For equal values, even if the types are inconsistent, the calculated hash value is the same.

>>> 1.0 == 1
True
>>> hash(1.0)
>>> hash(1)
>>> hash(1.0000)
Copy after login

The above is the detailed content of Detailed introduction to Python's built-in hash function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!