哈希方法主要有MD、SHA、Murmur、CityHash、MAC等几种方法。mmh3全程murmurhash3,是一种非加密的哈希算法,常用于hadoop等分布式存储情境中,在anaconda中安装使用命令
pip install mmh3
报错如下:
Microsoft Visual C++ 14.0 is required
显示缺少C++ 14的库文件,选择登录网站 /
下载Visual Studio2015,自动安装后运行
pip install mmh3
报错如下:
error: command ' failed: No such file or directory
在Visual Studio Installer中(工具栏-获取工具与功能),选择添加红框标注功能
建议安装的版本的Visual Studio2015,因为2015对应的是C++ 14的版本,如果是python2的mmh3需要对应C++ 9的版本,这主要是因为python2是基于C++ 9编译的,python3是基于C++ 14编译的,亲测安装VS2019并没有解决C++ 14缺失的问题。
样例:
>>> import mmh3
>>> mmh3.hash('foo')
# 32 bit signed int
-156908512>>> mmh3.hash('foo', 42)
# uses 42 for its seed
-1322301282>>> mmh3.hash('foo', signed=False)
# 32 bit unsigned int (since Version 2.5)
4138058784>>> mmh3.hash64('foo')
# two 64 bit signed ints (by using the 128-bit algorithm as its backend)
(-2129773440516405919, 9128664383759220103)>>> mmh3.hash64('foo',signed =False) # two 64 bit unsigned ints
(16316970633193145697, 9128664383759220103)>>> mmh3.hash128('foo', 42)
# 128 bit unsigned int
215966891540331383248189432718888555506>>> mmh3.hash128('foo', 42, signed = True)
# 128 bit signed int
-124315475380607080215185174712879655950>>> mmh3.hash_bytes('foo')
# 128 bit value as bytes
'aExf5x01Wx86qxe2x87}xba+xe4x87xaf~'
本文发布于:2024-02-04 10:52:52,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170705513754923.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |