[英]how to perform math operation on a variable into flask template
I just need to perform this我只需要执行此操作
{% i += 1 %}
but I end with this error但我以这个错误结束
jinja2.exceptions.TemplateSyntaxError:
expected token 'end of statement block', got '+'
I reached this point {% set i = sum([i, 1]) %}
我达到了这一点{% set i = sum([i, 1]) %}
but within for loop it prints 111111111 not 123456789 '_'但在 for 循环中它打印 111111111 而不是 123456789 '_'
try to do the following code, just do the math operation before.尝试做下面的代码,只是做之前的数学运算。 it worked for me.它对我有用。
i+=1
return render_template("file.html",i=i)
And write in your html file the following line:并在您的 html 文件中写入以下行:
<p>{{i}}</p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.