list为Unicode编码,这样中文输出为Unicode编码
我们可以将list转换为字符串,这样就可以转换编码,输出字符了。
# coding:utf-8
def recode(str1):
str2 = ""+str1
str2 = str2.decode("utf-8")
return str2
list = ["吃饭没", "睡觉没"]
str = ""+list[0]
str1 = recode(list[1])
str = str.decode("utf-8")
print "直接输出list: ".decode("utf-8"), list
print "转换为字符串输出: ".decode("utf-8"), str, str1