码迷,mamicode.com
首页 > 编程语言 > 详细

python-unicode十进制数字转中文

时间:2014-12-04 23:12:49      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   os   for   on   div   2014   

bubuko.com,布布扣

#coding:utf-8

‘‘‘主要是unichr()函数。以下数组中的元素转换后为繁体中文,若不加encode("GB18030")就不能正确显示,而且会报错:(‘gbk‘ codec can‘t encode character u‘\ue5fa‘ in position 0:illegal multibyte sequence)‘‘‘

str1=[58874,12417,58859,12417,58896,57809]

for x in str1:
    print unichr(x).encode("GB18030"),

  

python-unicode十进制数字转中文

标签:blog   http   io   ar   os   for   on   div   2014   

原文地址:http://www.cnblogs.com/jhcla/p/4145206.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!