字符编码

#!/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')


字符编码
posted @ 2017-03-31 13:52  beiguuu  阅读(140)  评论(0编辑  收藏  举报