我不理解在python中使用Mako模板的文檔。我有一個Python文件,我有以下代碼:試圖在python中使用Mako模板來呈現json數據
import json, requests, urllib2
from mako.template import Template
from mako.lookup import TemplateLookup
from pylons.templating import render_mako as render
url="www.data&format=json"
response = urllib2.urlopen(url)
data = json.load(response)
return (Template("hello Luisito! Here is the data: ${data}!").render(json_data=data))
可能有人爲我提供有關如何使用灰鯖模板來呈現這個JSON數據到一個網頁一些細節?我需要另一個文件與模板?如果是這樣,怎麼樣?
哪一部分你的問題在這裏需要一個HTML模板庫字符串格式化無法實現? –
你使用什麼web框架?你應該閱讀關於該文件。 「def navigation(self):」本身無所作爲。 –
@ cricket_007基本上輸入將是一個json對象,我想用模板來顯示該對象的結果 – Luisito