from https://blog.csdn.net/sinat_24648637/article/details/84190482
1. chardet模塊
舉例
2. Supported encoding for python
1. chardet模塊
The easiest way to use the Universal Encoding Detector library is with the detect function.
使用通用編碼檢測器庫的最簡單方法是使用detect函數
The detect function takes one argument, a non-Unicode string. It returns a dictionary containing the auto-detected character encoding and a confidence level from 0 to 1.
detect函數有一個參數, 即非 unicode 字符串。它返回一個字典, 其中包含自動檢測的字符編碼和從0到1的置信度。
舉例
>>> import chardet
>>> chardet.detect('abc123')
{'confidence': 1.0, 'encoding': 'ascii'}
>>> chardet.detect('中國')
{'confidence': 0.7525, 'encoding': 'utf-8'}
1
2
3
4
5
2. Supported encoding for python
截圖來自https://chardet.readthedocs.io/en/latest/usage.html#example-using-the-detect-function
---------------------
作者:blank4569
來源:CSDN
原文:https://blog.csdn.net/sinat_24648637/article/details/84190482
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!