mako模板变量划分

2024-09-30 01:29:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用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)
%>

有办法让我的部门工作吗?在


Tags: 代码in模板nodeformakohtmlcount

热门问题