英文文檔: 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 duri ...
英文文檔:
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