python调用高德API计算两地点之间的距离

  1. 注册成为高德开发者
  2. 调用接口的示例程序
import json
import requests
# 拼接url
url_head = 'https://restapi.amap.com/v3/distance?key=<你自己的key>' # 记得把key替换了
from_ = "&origins=" # 起点
from_ += str(10.10333)+','+str(10.10023) # 起点坐标
destination = "&destination="+str(10.10) + ','+str(10.103) # 终点
all_url = url_head + from_ + destination
# 发送请求
data = json.loads(requests.get(all_url).text)
print(data)

你可能感兴趣的:(python)