我有一本字典遍歷,我印在我的網頁,並得到這個:Django模板 - 如何迭代和訪問字典?
dict = {
u'256': <itertools._grouper object at 0x8361d0e90>,
u'59': <itertools._grouper object at 0x83607c110>,
u'59': <itertools._grouper object at 0x83607c050>,
u'1975555': <itertools._grouper object at 0x8361bc490>,
u'91': <itertools._grouper object at 0x836162110>
}
我如何可以訪問字典此對象的值是多少? 這裏是我曾嘗試:
{% for code, codelist in dict.items %}
{% for innerlists in codelist %}
// Here I want to display the values in the dict's object
{% endfor %}
{% endfor %}
你能展示你的字典在視圖中是怎麼看的? – Ander2
在你的視圖中,對你的字典的值做一個'list()'。 –
您不應該重新定義'dict'關鍵字 – Paco