我有html格式的表格:
ab=[24,56,78]
<table >
<tr><th>ab</th>
{% for d in ab %}
<td>{{ d }}</td>
{% endfor %}
</tr>
</table>
我知道{{d|add:100}}
,但它是加法,我怎么做乘法呢?我需要以百分比表示的数字
ab
是一个列表。如何在html表的循环内将列表ab乘以100?这到底有没有可能?
发布于 2020-04-15 13:40:45
你也可以使用宽比内建滤波器进行乘法和除法运算。
计算A*B:{% widthratio A1 B%}
计算A/B:{% widthratio A B 1%}
注意:对于无理数,结果将四舍五入为整数。
发布于 2022-01-17 10:42:53
{{d|mul:100}}应该会为你做乘法运算。有关更多详情,请访问以下链接:https://pypi.org/project/django-mathfilters/
https://stackoverflow.com/questions/61229255
复制