Python调用高德API,实现批量获取地址经纬度,并写入excel文件
调用高德API实现批量输入地址,获取经纬度,并输出到excel表格
# 导入库
import requests,json
import xlsxwriter
# 定义变量
KEY = 'xxx' #此处填入你申请的key
URL_geocode = 'https://restapi.amap.com/v3/geocode/geo?'
# 获取经纬度
def gain_location(address):
api_url = f'{URL_geocode}city=郑州市&address={address}
&key={KEY}&output=json&callback=showLocation' #此处城市名可更改
r = requests.get(api_url)
r = r.text
r = r.strip('showLocation(')
r = r.s
共有 0 条评论