第四个elif语句是导致我这个问题的原因。我已经把第三个elif语句和第四个交换了,每次第四个在第三位时它都能工作。
{% block content%}
{% load static %}
<link rel="stylesheet" href="{% static 'css/home_page.css' %}">
<link rel="stylesheet" href="{% static 'css/home_w_d_cs.css' %}">
{% if first_hour_d == 'clear sky' and time_of_day == True %} <!-- day == True means day -->
<div class="side-hour-icon">
<img src="{% static 'images/sunny-black.png' %}" alt="" width="55" height="50">
</div>
{% elif first_hour_d == 'clear sky' and time_of_day == False %} <!-- day == False means night -->
<div class="side-hour-icon">
<img src="{% static 'images/clear-night-black.png' %}" alt="" width="55" height="50">
</div>
{% elif first_hour_d == 'overcast clouds' or 'broken clouds' %}
<div class="side-hour-icon">
<img src="{% static 'images/cloudy2.png' %}" alt="" width="55" height="50">
</div>
{% elif first_hour_d == 'few clouds' or 'scattered clouds' %}
<div class="side-hour-icon">
<img src="{% static 'images/few-clouds-black.png' %}" alt="" width="55" height="50">
</div>
{% endif %}
{% endblock %}
我想有几个elif语句,也许10个或12个。这可能吗?
1条答案
按热度按时间2skhul331#
您不能执行以下操作:
因为第二个字符串的计算结果总是
True
。您必须: