我正在使用mako创建html模板。在
我的模板,我有以下代码:
% for s in query['sandboxes']:
% for node in s['nodes']:
<table>
<tr>
<td>${node['node_name']}</td>
<td>${node['slowcall_count']}) / ${s['slowcall_count']}</td>
</tr>
</table>
% endfor
% endfor
循环和显示器工作,但它显示“30/100”而不是实际的除法结果。在
搜索之后,我看到了这个Using from __future__ import in Mako template
然后尝试了以下代码:
^{pr2}$但它给了我一个语法错误。以下显示也不会显示任何错误:
<td>
<%!
float(1) / float(2)
%>
有办法让我的部门工作吗?在
这应该适用于td标签:
表达式可以出现在${}中。如下所述:
http://docs.makotemplates.org/en/latest/syntax.html#expression-substitution
相关问题 更多 >
编程相关推荐