dawn-liu

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
import chardet

a=b'\xe4\xbd\xa0\xe5\xa5\xbd\xef\xbc\x8c\xe4\xb8\x96\xe7\x95\x8c\xe3\x80\x82'
print(chardet.detect(a)) # {'encoding': 'utf-8', 'confidence': 0.99, 'language': ''}
print(a.decode('utf-8')) # 你好,世界。
这个模块多用于跨语言得到结果,或者爬虫

 

posted on 2019-11-19 14:31  dawn-liu  阅读(413)  评论(0编辑  收藏  举报