Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当我将内容类型设置为application/json时,如何防止转义序列?_Python_Html_Json_Jsonp_Web.py - Fatal编程技术网

Python 当我将内容类型设置为application/json时,如何防止转义序列?

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

我的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/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)