我有一个python字典,看起来像这样
[{"hat": 91, "d1b": 2, "d1c": 1, "d1d": 5, "d1e": 7, "d1f": 77, "d1e": 999}
{"hat": 1, "d2b": 2, "d2c": 3, "d2d": 4, "d2e": 5, "d2f": 6, "d2e": 7}
{"hat": 1, "d3b": 2, "d3c": 3, "d3d": 4, "d3e": 5, "d3f": 6, "d3e": 7}]
我把它作为dictionary对象(mydict)从python传递给jinja
我要做的是遍历每个字典并打印出我搜索的键的值。并在jquery警报框中显示。在
^{pr2}$当我进入我的网页时,它会给我一个错误
Uncaught SyntaxError: Unexpected token &
$(document).ready(function() {
0, (Undefined, [[hat[])
alert( );
1, (Undefined, [hat])
alert( );
2, (Undefined, [hat])
alert( );
});
它没有被定义,也没有打印警报。在
您需要像python一样调用dictionary(它不是collection):
集合可以作为字典访问,而字典不能作为集合调用。任何你需要的方法都可以使用i.hat如果是一个集合或字典,i['hats']。在
试着把它换掉:
^{pr2}$收件人:
相关问题 更多 >
编程相关推荐