如何在一个四循环中获取不同的数据?

问题描述 投票:0回答:1

views.py

定义索引(请求):

test = Test()
time = test.full_day_time()[0]
today = test.today_forecast()

context={'min_temperature' :  [np.min(today['temperature_2m'][i:i+3]) for i in range(0,24,3)],
         'max_temperature':   [np.max(today['temperature_2m'][i:i+3]) for i in range(0,24,3)],
         'temperature': today['temperature_2m'],
         'time': time,
         'range': range(6)
         }

return render(request, 'new_base.html', context)

我想要得到这样的东西, 但这不起作用

index.html

{% for i in range %}

{{min_温度.i}}

{% endfor %}

python django-templates
1个回答
0
投票

您不需要在视图或模板中使用范围变量。

只需如下使用即可。

{% for i in min_temperature %}

{{i}}

{% endfor %}
© www.soinside.com 2019 - 2024. All rights reserved.