Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在模板中显示类似字符串的列表?
Yeah!{{msg}}
示例输出:
是的!['您已成功更改此设置!']
我需要以这种方式显示:
是的!您已成功更改此设置!
你可以做
Yeah! {% for m in msg %}{{m}}{% endfor %}
这样,如果列表中有多条消息,则可以显示所有内容
使用列表的第一个元素:
{{ msg.0 }}
如果您的列表存在更多项目,您可以通过循环显示它们:
{% for item in msg %} {{ item }} {% endfor %}