【发布时间】:2023-03-16 02:53:01
【问题描述】:
请告诉我如何在一个命令中使用数组和变量? 因为在 django 中我有错误:
“无法解析余数:'[show]' from 'host_value[show]'”
这是我的代码:
<form action="" method="post" >{% csrf_token %}
{% for show in showing %}
<p><input id="autocomplete{{show}}" size="35" value="{{host_value[show]}}" name="hosts{{show}}" title="type "hostname""></p>
{% endfor %}
</form>
我的输入值有问题,我尝试从数组 host_value 中设置值,索引为“show”
我该怎么做?
【问题讨论】:
-
你用的是数组还是字典???
-
没有数组,比如我的host_value是:[u'zabbix2', u'Zabbix server']
-
那么什么是“显示”,因为它看起来像一个索引?
-
显示这个变量,显示数字从 0 到我的设置显示数字