2024-09-27 00:12:03 发布
网友
我试图找到与python哈希函数等价的Go:
hash("test")
我发现this post是一个非常类似的函数,它返回一个整数,然而,它使用了fnv,这似乎是一个不同于python version的散列方法
我要做的是把一个字符串传递给hash函数,这样它在两种语言中为同一个字符串返回完全相同的整数。你知道吗
By default, the __hash__() values of str, bytes and datetime objects are “salted” with an unpredictable random value. Although they remain constant within an individual Python process, they are not predictable between repeated invocations of Python.
__hash__()
在Python脚本的不同调用之间会得到不同的数字。所以我觉得你想要什么都不可能。你知道吗
资料来源:https://docs.python.org/3.5/reference/datamodel.html#object.__hash__
在Python脚本的不同调用之间会得到不同的数字。所以我觉得你想要什么都不可能。你知道吗
资料来源:https://docs.python.org/3.5/reference/datamodel.html#object.__hash__
相关问题 更多 >
编程相关推荐