【发布时间】:2020-03-14 23:33:12
【问题描述】:
我有一个 python 脚本,它可以为不同影院的电影抓取一些页面,并使用烧瓶将结果显示在 html 页面中。我从我的 python 脚本中传递了一个列表,该列表至少包含 1 个元素(剧院名称)并遍历列表的其余部分(今日电影)并打印它。
在 html 中我想检查这个列表的长度。如果 list = 1 我想打印一条说明没有可用的文本。这是我的html代码
<div class="theater">
<div class="row_header">
{{ my_theater[0] }}
</div>
<div class="row_sub_header">
Opening at 11am
</div>
{% if my_theater|length == 1 %} {{ my_theater.append("No movies available today") }} {% endif %} {% for m in my_theater[1:] %}
<div class="row">
<div class="cell">
{{ m }}
</div>
</div>
{% endfor %}
<div class="row_sub_header2">
<p>Price: 10 USD</p>
</div>
</div>
And this is the html output (screenshot):
html中怎么会显示“none”,如何去掉?
【问题讨论】:
标签: python html flask web-scraping jinja2