chardet识别文字编码

cooolr 于 2023-04-21 发布
  1. 安装

     pip install charet
    
  2. 使用

     import chardet
        
     print(chardet.detect("hello world".encode())['encoding'])
     print(chardet.detect("你好帅啊".encode())['encoding'])
    

    输出

     ascii
     utf-8