Python Chardet 通用字符编码检测器
Chardet Python字符编码检测器
Chardet Python第三方库,可用于字符编码的检测。这个在需要检测数据的编码,比如大数据处理网页数据需要获悉网页数据编码的时候,可能会使用到。Chardet支持检测多种字符编码,如下:
- ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants)
- Big5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN (Traditional and Simplified Chinese)
- EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP (Japanese)
- EUC-KR, ISO-2022-KR, Johab (Korean)
- KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, windows-1251 (Cyrillic)
- ISO-8859-5, windows-1251 (Bulgarian)
- ISO-8859-1, windows-1252, MacRoman (Western European languages)
- ISO-8859-7, windows-1253 (Greek)
- ISO-8859-8, windows-1255 (Visual and Logical Hebrew)
- TIS-620 (Thai)
Github stars
LGPL-2.1 license
Github 2k stars
Chardet安装命令
pip install chardet
Python版本要求
Python 3.7+
Chardet文档
Github:Chardet
Documentation:Chardet
Chardet简单的应用实例
import chardet
print(chardet.detect(b'Hello, world! Hello, DeepLearning'))
输出(其中confidence类似于置信度):
{'encoding': 'ascii', 'confidence': 1.0, 'language': ''}
免责声明:内容编辑自网络,仅供参考,不保证正确性,不作任何决策依据!!以上数据皆截止于博文的写稿日期。