python中文编码问题


  1. python2键盘读入中文默认格式gbk

  2. 从其他格式编码转为unicode编码,例如从utf-8转为unicode,str.decode(‘utf-8’)
    从unicode编码转为其他格式编码,例如从unicode转为utf-8,str.encode(‘utf-8’)

  3. 查询编码格式

import chardet
str = '测试'
print chardet.detect(str)

转载自:https://blog.csdn.net/foxqz/article/details/83545860

You may also like...

退出移动版