Python 当我将内容类型设置为application/json时,如何防止转义序列?
我的API需要返回json类型的内容,所以我将内容类型设置为application/json 这是我的,我不想让角色逃脱 我使用webpy框架Python 当我将内容类型设置为application/json时,如何防止转义序列?,python,html,json,jsonp,web.py,Python,Html,Json,Jsonp,Web.py,我的API需要返回json类型的内容,所以我将内容类型设置为application/json 这是我的,我不想让角色逃脱 我使用webpy框架 def GET(self): web.header('Content-Type', 'application/json') url = "http://www.reddit.com/r/pics/hot.json" hdr = { 'User-Agent' : 'super happy flair bot by /u/spladu
def GET(self):
web.header('Content-Type', 'application/json')
url = "http://www.reddit.com/r/pics/hot.json"
hdr = { 'User-Agent' : 'super happy flair bot by /u/spladug' }
req = urllib2.Request(url, headers=hdr)
html = urllib2.urlopen(req).read()
gold = json.loads(html)
return render.callback(gold)
这是示例输出:
{u'kind': u'Listing'}
我不想让这个角色逃脱
有人能帮我吗?我觉得新浪应用程序在这里出了问题,但我没有这方面的经验,文档都是中文的。@frb-thx,我在问题中添加了输出,你能看一下吗?
# If ensure_ascii is True (the default),
# all non-ASCII characters in the output are escaped.
gold = json.loads(html, ensure_ascii=0, sort_keys=1, indent=4)