Python Web.py模板字典

Python Web.py模板字典,python,web.py,Python,Web.py,从我在web.py中传递给模板的字典中获取数据时遇到问题 例如,当我使用 return render.resp({'foo':'bar'}) 然后在我的模板中尝试 $def with (test) $test.foo 我得到错误“'dict'对象没有属性'foo'”这不是访问字典的正确语法。试试这个: $test['foo'] 或者,传入一个web.storage: return render.resp(web.storage({'foo': 'bar'}))

从我在web.py中传递给模板的字典中获取数据时遇到问题

例如,当我使用

return render.resp({'foo':'bar'})
然后在我的模板中尝试

$def with (test)
$test.foo

我得到错误“'dict'对象没有属性'foo'”

这不是访问字典的正确语法。试试这个:

$test['foo']
或者,传入一个
web.storage

return render.resp(web.storage({'foo': 'bar'}))