【发布时间】:2016-12-27 20:29:17
【问题描述】:
我从数据库中选择了一行包含一些 json 内容的行
我的功能选择行
@route('/list')
def list():
c = conn.cursor()
c.execute("SELECT content FROM pages WHERE URL = 'blob.com'")
select = c.fetchall()
return template('views/list.tpl', rows=select)
“内容”行的结果是:
{ "ruleGroups": {
"SPEED": { "score": 97 }
},
"pageStats": { "numberResources": 3,
"numberHosts": 2,
"totalRequestBytes": "500",
"imageResponseBytes": "3148",
"otherResponseBytes": "3838"
},
"screenshot": { "mime_type": "image/jpeg",
"data": "imgcontent",
"width": 320,
"height": 240,
}
}
我想从json“score”、“numberResources”和“numberHosts”中显示在list.tpl中。
我应该如何处理 list.tpl?
【问题讨论】:
-
我不确定我是否理解,也许:
content['ruleGroups']['SPEED']['score'];content['pageStats']['numberResources'];content['pageStats']['numberHosts']?
标签: python json templates bottle