Python 字符編碼檢測庫:PyCharlockHolmes

n6xb 9年前發布 | 15K 次閱讀 Python開發 PyCharlockHolmes

PyCharlockHolmes 是豆瓣開發的一個 Python 的字符編碼檢測庫。基于 ICU 和 libmagic 開發,靈感來自于 Charlock Holmes

Dependency

  1. icu
  2. file(libmagic)

Gentoo

emerge -av dev-libs/icu
emerge -av sys-apps/file

Ubuntu

apt-get install libicu-dev
apt-get install libmagic-dev

Brew

brew install icu4c
brew install libmagic
export ICUI18N="/usr/local/Cellar/icu4c/xx" # Replace "xx" as the version of your icu
export MAGIC="/usr/local/Cellar/libmagic/xx" # Replace "xx" as the version of your libmagic

Install

python setup build
python setup install

Usage

from charlockholmes import detect
file = open('test.txt')
content = file.read()
print detect(content)

項目主頁:http://www.baiduhome.net/lib/view/home/1428388203901

 本文由用戶 n6xb 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!