from pathlib import Path import json # 读取作为字符串的数据并转换为Python对象。 path = Path('eq_data/eq_data_1_day_m1.geojson') contents = path.read_text() all_eq_data = json.loads(contents) # 获取数据集中地震列表。 all_eq_dicts = all_eq_data['features'] mags, titles, lons, lats = [], [], [], [] for eq_dict in all_eq_dicts: mag = eq_dict['properties']['mag'] title = eq_dict['properties']['title'] lon = eq_dict['geometry']['coordinates'][0] lat = eq_dict['geometry']['coordinates'][1] mags.append(mag) titles.append(title) lons.append(lon) lats.append(lat) print(mags[:10]) print(titles[:2]) print(lons[:5]) print(lats[:5])