<p>我有一个jinja2<code>if</code>语句,我在其中检查字典项是否等于id,但是它似乎永远无法正确地或根本没有对其求值。在</p>
<p>以下是我的<code>if</code>声明:</p>
<pre><code><select id="deviceTypes" class="inputBoxes" style="height: 25px;">
{% for key, value in deviceTypes.iteritems() %}
{% if deviceTypeID == key %} --> deviceTypeID is defined but this block of code never runs (key is an integer value, it's the id of the option)
<option value="{{key}}" selected>{{deviceTypeID}}</option>
{% else %}
<option value="{{key}}">{{value}}</option>
{% endif %}
{% endfor %}
</select>
</code></pre>