我试图读取json格式的元数据(从http://jmcauley.ucsd.edu/data/amazon/links.html)。 它具有以下错误。 有没有人可以帮助我?
for (i in polygons) {
var coords = polygons[i]["coordinates"];
var style = getStyle(polygons[i]["category"]);
var popup = ""; // fill it as you wish
// Directly build a Leaflet layer instead of an intermediary GeoJSON Feature
var itemLayer = L.polygon(coords, style).bindPopup(popup);
itemLayer.id = polygons[i]["ID"];
itemLayer.addTo(Hazards);
}
function getStyle(category) {
switch (category) {
case 'Rabid_Beavers': return {color: "#663326"};
case 'Fire': return {color: "#ff0000"};
case 'Flood': return {color: "#0000ff"};
}
}
答案 0 :(得分:0)
请尝试以下代码:
with open('dumps/all_products.json', 'r') as fd:
content = json.loads(fd.read())