如何分配jinja2变量值以便在模板中稍后使用?如何分配jinja2变量值以便在模板中稍后使用?
{% if 'clear' in forcast_list[4] %}
{% img = "sunny.png" %}
{% elif "cloudy" in forcast_list[4] %}
{% img = "sun-cloudy-thunder.png" %}
{% endif %}
<div style="background: right bottom no-repeat url('../static/img/{{img}}')" class="weather-icon-pos">
<!-- weatehr Icon div -->
</div>
任何帮助将不胜感激。
Jinja2的变量从您的水壶应用程序通过。你必须在'render_template()'代码中指定它们 – Mangohero1