1.列表类型(用join方法)
myUlist = [u'AB', u'AB', u'AB', u'AB']
print myUlist
print ", ".join(myUlist)
2.字典类型
[{u'sum(id)': Decimal('28'), u'month': 3}, {u'sum(id)': Decimal('1'), u'month': 12}]
from unicode import ToUnicode
li = []
for item in ret:
print item
dic = {}
for key, value in item.items():
# 借助于单个字符串的方法
dic[ToUnicode(key)] = value
li.append(dic)
print li
3.单个字符串
def ToUnicode(s):
try:
s = str(s.decode("GBK").encode("utf-8"))
except:
s1 = ''
s2 = ''
L = []
s2 = str(list(s.decode('GBK')))
s2 = s2.replace("u'", "'")
s2 = s2.replace("\", "%")
L = eval(s2)
for e in L:
s1 += e
s = s1.encode("utf-8")
return s