簡體   English   中英

我將一個變量從 python 到 flask 傳遞給 html,如果該值小於或大於數字,有沒有辦法顯示某個圖像?

[英]im passing a variable into html from python through flask, is there a way to display a certain image if the value is less or more than a number?

我想我問的是有沒有辦法在 html 中做邏輯? 如果不是,那么做我想做的最好的方法是什么?

有沒有辦法做類似的事情

if {{ fkdr }} < 1:
    <img src="image.png" width="250" height="250">

如果您使用的是 Flask 的render_template ,那么是的,您可以使用 Jinja 的if語句:

{% if fkdr < 1 %}
    <img src="image.png" width="250" height="250">
{% else %}
    Do something when there is no fkdr... or delete this else block leaving the endif below
{% endif %}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM