list编码问题python-2.7

来源:互联网 发布:matlab数据分析 编辑:程序博客网 时间:2024/06/05 07:49

list为Unicode编码,这样中文输出为Unicode编码

我们可以将list转换为字符串,这样就可以转换编码,输出字符了。


# coding:utf-8def recode(str1):    str2 = ""+str1    str2 = str2.decode("utf-8")    return str2list = ["吃饭没", "睡觉没"]str = ""+list[0]str1 = recode(list[1])str = str.decode("utf-8")print "直接输出list:     ".decode("utf-8"), listprint "转换为字符串输出:  ".decode("utf-8"), str, str1





原创粉丝点击