我想从嵌套 for 循环中的最后一个对象中删除逗号:
[{% for item1 in articles.results.entities %}
{% for item2 in articles1.results.entities %}
{% if item1.knowledgearticleid != item2.knowledgearticleid %}
{
"Id":"{{item1.knowledgearticleid}}",
"Title":"{{item1.title}}",
"Articlepublicumber":"{{item1.articlepublicnumber}}",
"Description":"{{item1.description}}"
}
{% endif %}
{% endfor %}
{% unless forloop.last %},{% endunless %}
{% endfor %}]
但这不起作用;它给了我重复的逗号:
[
{
"Id": "ddcb41c6-1f33-ea11-a813-000d3a3be5cf",
"Title": "1 Test1",
"Articlepublicumber": "KA-01992",
"Description": "Test1"
},,
{
"Id": "9564dc21-9df6-414b-ab99-da4ba534fd83",
"Title": "Test2",
"Articlepublicumber": "KA-03363",
"Description": "Test2"
}
]