Javascript 迭代对象列表

Javascript 迭代对象列表,javascript,python,django,Javascript,Python,Django,我有一个列表,列表中有对象,我需要遍历所有列表中的每个对象。这是我尝试过的,但没有按照我的意愿去做 dict_values([[<mapvis.store.Node object at 0x14fd370>, <mapvis.store.Node object at 0x13c4270>], [<mapvis.store.Node object at 0x14fd930>, <mapvis.stor

我有一个列表,列表中有对象,我需要遍历所有列表中的每个对象。这是我尝试过的,但没有按照我的意愿去做

dict_values([[<mapvis.store.Node object at 0x14fd370>, <mapvis.store.Node object at 0x13c4270>], [<mapvis.store.Node object at 0x14fd930>, <mapvis.store.Node object at 0x14fd490>], ])
Js函数

function displayRoads(map) {
  {% for create_lat_lng in get_lat_lng %}
        {% for lat_lng in create_lat_lng %}
        var points = new google.maps.MVCArray();
        points.push(new google.maps.LatLng(lat_lng[0].lat, lat_lng[0].lng));
        points.push(new google.maps.LatLng(lat_lng[1].lat, lat_lng[1].lng));
        createPolyline(map, points);
  {% endfor %}
{% endfor %}
}
生成的Html。我希望它具有实际值,而不是lat_lng[0]。lng

function displayRoads(map) {
    var points = new google.maps.MVCArray();
    points.push(new google.maps.LatLng(lat_lng[0].lat, lat_lng[0].lng));
    points.push(new google.maps.LatLng(lat_lng[1].lat, lat_lng[1].lng));
    createPolyline(map, points);
...
..
...
}

使用
{{variable}
语法

function displayRoads(map) {
  {% for create_lat_lng in get_lat_lng %}
      {% for lat_lng in create_lat_lng %}
        var points = new google.maps.MVCArray();
        points.push(new google.maps.LatLng({{ lat_lng.0.lat }}, {{ lat_lng.0.lng }}));
        points.push(new google.maps.LatLng({{ lat_lng.1.lat }}, {{ lat_lng.1.lng }}));
        createPolyline(map, points);
      {% endfor %}
  {% endfor %}
}

为了澄清,
{{lat_lng.0.lat}
意味着访问
lat_lng
变量上的索引零,然后获取字典键
lat
的值。因此,上面的代码假设
lat_lng
是一个包含字典的数组/元组。

在问题中添加了更多信息,它没有给我这样的值;points.push(新的google.maps.LatLng(,);
lat\u lng
是数组还是字典?根据你的代码,我假设它是一个数组。如果是字典,您可以尝试
{{lat_lng.lat}}
{{lat_lng.lng}}
。我需要知道
lat_lng
变量的实际结构,以便为您提供准确的答案。