缩短施工时间

2024-09-26 17:48:33 发布

您现在位置:Python中文网/ 问答频道 /正文

挑战是减少构造,如果可能的话,加快代码的处理。你知道吗

{% for tp1 in test.tab_tp1s %}
    {{ tp1.name }}
{% endfor %}
{% for tp2 in test.tab_tp2s %}
    {{ tp2.name }}
{% endfor %}
{% for tp3 in test.tab_tp3s %}
    {{ tp3.name }}
{% endfor %}

Tags: 代码nameintestfortabtp3endfor
1条回答
网友
1楼 · 发布于 2024-09-26 17:48:33
{% for tab in test %}
    {% for tp in test[tab]
        {{ tp.name }}
    {% endfor %}
{% endfor %}

可能很难说,因为我们不知道存储在test中的是什么,我假设test是一个包含3个键的字典,每个键都包含一个子键name?你知道吗

相关问题 更多 >

    热门问题