首页 > 编程语言 > 详细

Python内置函数(28)——hash

时间:2016-10-29 11:35:56      阅读:261      评论:0      收藏:0      [点我收藏+]

英文文档:

hash(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).

 

说明:  

  1. 返回对象的哈希值,用整数表示。哈希值在字典查找时,可用于快速比较键的值。

>>> hash(good good study)
1032709256

  2. 相等的数值,即使类型不一致,计算的哈希值是一样的。

>>> 1.0 == 1
True
>>> hash(1.0)
1
>>> hash(1)
1
>>> hash(1.0000)
1

 

Python内置函数(28)——hash

原文:http://www.cnblogs.com/sesshoumaru/p/6010180.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!