我有一个python列表:categoriesPython,它是['Firefox 2.0','Firefox 3.0','Firefox 3.5','Firefox 3.6','Firefox 4.0'], 我做了(我正在使用web.py):
data: {
name: 'Firefox versions',
categories: $categoriesPython,
version: [0.20, 0.83, 1.58, 13.12, 5.43]
}
我希望得到:
data: {
name: 'Firefox versions',
categories: ['Firefox 2.0', 'Firefox 3.0', 'Firefox 3.5', 'Firefox 3.6', 'Firefox 4.0'],
version: [0.20, 0.83, 1.58, 13.12, 5.43]
}
然而,我得到了:
data: {
name: 'Firefox versions',
categories: ['Firefox 2.0', 'Firefox 3.0', 'Firefox 3.5', 'Firefox 3.6', 'Firefox 4.0'],
version: [0.20, 0.83, 1.58, 13.12, 5.43]
}
1。由于数据是Json格式,因此不能有任何赋值,例如:
data: {
name: 'Firefox versions',
categorieData.push('$categoriesPython');
categories: categorieData,
version: [0.20, 0.83, 1.58, 13.12, 5.43]
}
另外,我不想将python列表转换为javascript列表,因为列表中有200多个值,如果转换,必须有超过200个categorieData.push('$ categoriesPython');,代码将多余的。
如何获得预期结果?
答案 0 :(得分:0)
从Filtering上的文档中可以看出
$:categoriesPython
可能会做到这一点
默认情况下,Templetor使用web.websafe过滤器进行HTML编码。
render.hello(“1< 2”)“Hello 1< 2”
关闭过滤器使用:$。之后。例如:
以下内容不会被html转义。 $:form.render()