首页 > 编程语言 > 详细

python字典中显示中文

时间:2017-07-14 14:19:20      阅读:265      评论:0      收藏:0      [点我收藏+]

#coding=utf-8
import json
dict={‘title‘:"这是中文"}
print json.dumps(dict,ensure_ascii=False,encoding="utf-8")

 

 

books=[
{‘name‘:u‘C#从入门到精通‘,‘price‘:23.7,‘store‘:u‘卓越‘},
{‘name‘:u‘C#从入门到精通二‘,‘price‘:44.5,‘store‘:u‘当当‘},
{‘name‘:u‘C#从入门到精通三‘,‘price‘:25.7,‘store‘:u‘新华书店‘},
{‘name‘:u‘C#从入门到精通四‘,‘price‘:25.8,‘store‘:u‘新华书店‘},
]
store=[]
for item in books:
for p in item:
if p==‘store‘:
store.append(item[p])
print json.dumps(store, ensure_ascii=False, encoding="utf-8")

 

["卓越", "当当", "新华书店", "新华书店"]

python字典中显示中文

原文:http://www.cnblogs.com/51testing/p/7169633.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!