使用Python修改JSON

seb*_*seb -2 python json geojson

属于这个问题的代码可以在github上找到.

我编写了一个脚本,用于解析csv文件中的地址,使用geopy查询相应的坐标(经度和纬度),并将输出写入JSON格式的文本文件.

将数据写入JSON文件的print语句不漂亮:

print('{"type": "Feature","geometry": { "coordinates": ['+str(location.longitude)+
    ','+str(location.latitude)+ ',],"type": "Point"},"properties": {"title": "dentist #1","privat": true,"marker-color": "#6699ff","marker-size": "large","marker-symbol": "dentist"}},')
    time.sleep(0.01)
    file.write('{"type": "Feature","geometry": { "coordinates": ['+str(location.longitude)+
    ','+str(location.latitude)+ ',],"type": "Point"},"properties": {"title": "dentist #1","privat": true,"marker-color": "#6699ff","marker-size": "large","marker-symbol": "dentist"}},')
Run Code Online (Sandbox Code Playgroud)

必须有更好(更简单)的方法来做到这一点.我已经开始谷歌了,但我对我发现的东西不满意.有没有人建议如何更优雅地处理Python中的JSON?