我的物品清单如下:
this_json_reponse = ['{"queskey": 1, "ques": "test question 1", "ans": "test ans 1"}', '{"queskey": 2, "ques": "test question 2", "ans": "test ans 2"}', '{"queskey":
5, "ques": "bfxgrdytreyt4etgest4", "ans": "3353tet4"}', '{"queskey": 6, "ques": "tet4w64t", "ans": "f464etrtd"}', '{"queskey": 7, "ques": "fdszf3r3647", "ans": "gry5757"}']
我从另一个API调用收到这个消息。
我只需要列出所有的queskey
和ques
现在:
1:试题1 2:试题2 ... 你知道吗
我尝试用嵌套循环解包,如下所示:
<ul>
{% for this_item in this_json_reponse %}
<li>{{ this_item }}</li>
{% for a,b in this_item.items %}
<li>{{ a }}</li>
{% endfor %}
{% endfor %}
</ul>
遗憾的是,经过长时间的打击/审判,我无法做到这一点。你知道吗
这是我的视图.py定义
this_json_reponse=this_reponse.json()
this_list=[]
for item in this_json_reponse:
this_list.append(item)
return render (request,"listall.html",{"this_json_reponse": this_list})
目前没有回答
相关问题 更多 >
编程相关推荐