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

python字典中显示中文

时间:2017-07-14 15:03:45      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:c#   books   sci   book   tle   显示   ensure   name   入门   

#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字典中显示中文

标签:c#   books   sci   book   tle   显示   ensure   name   入门   

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

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