首页 > 技术文章 > 字符编码

yangxiang1 2017-03-31 13:52 原文

#!/usr/bin/python
# -*- coding: UTF-8 -*-
在python2中测试
i = '中国'
print [i.decode('utf-8')] #16进制
gbk = i.decode('utf-8').encode('GBK') #utf-8转gbk
# print i.decode('GBK').encode('utf-8') #utf-8转gbk
print gbk.decode('GBK').encode('utf-8')
print gbk.decode('GBK').encode('gb2312')


字符编码

推荐阅读