關(guān)于python的mmh3庫安裝以及使用詳解
mmh3安裝方法
哈希方法主要有MD、SHA、Murmur、CityHash、MAC等幾種方法。
mmh3全程murmurhash3,是一種非加密的哈希算法,常用于hadoop等分布式存儲情境中,在anaconda中安裝使用命令
pip install mmh3
問題1
報錯如下:
Microsoft Visual C++ 14.0 is required
顯示缺少C++ 14的庫文件,選擇登錄網(wǎng)站 https://visualstudio.microsoft.com/downloads/ 下載Visual Studio2015,自動安裝后運行
pip install mmh3
問題2
報錯如下:
error: command 'cl.exe' failed: No such file or directory
在Visual Studio Installer中(工具欄-獲取工具與功能),選擇添加紅框標(biāo)注功能
其他說明
建議安裝的版本的Visual Studio2015,因為2015對應(yīng)的是C++ 14的版本,如果是python2的mmh3需要對應(yīng)C++ 9的版本,這主要是因為python2是基于C++ 9編譯的
python3是基于C++ 14編譯的,親測安裝VS2019并沒有解決C++ 14缺失的問題。
mmh3使用
樣例:
>>> 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 'aE\xf5\x01W\x86q\xe2\x87}\xba+\xe4\x87\xaf~'
到此這篇關(guān)于關(guān)于python的mmh3庫安裝以及使用詳解的文章就介紹到這了,更多相關(guān)python的mmh3庫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python項目打包成apk或者其他端的應(yīng)用程序
本文主要介紹了使用Kivy和Buildozer將Python項目打包成Android APK文件的步驟,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-11-11