Django模板语言循环字典
1. 对于字典,可以有下列用法:
{% for row in user_dict.keys %}
{% for row in user_dict.values %}
{% for row in user_dict.items %} 得到元组
{% for k,row in user_dict.items %}
<li>{{k}}-{{row}}</li>
{% endfor %}
2. views.py中程序
程序及运行结果:
1. 对于字典,可以有下列用法:
{% for row in user_dict.keys %}
{% for row in user_dict.values %}
{% for row in user_dict.items %} 得到元组
{% for k,row in user_dict.items %}
<li>{{k}}-{{row}}</li>
{% endfor %}
2. views.py中程序
程序及运行结果: