要解析经纬度地址,需要使用地理编码服务。Google Maps提供了一个免费的地理编码API,可以使用Python的requests库向API发送请求并解析响应。以下是一个示例代码:

import requests

url = 'https://maps.googleapis.com/maps/api/geocode/json'
params = {'address': '1600 Amphitheatre Parkway, Mountain View, CA'}
response = requests.get(url, params=params)
data = response.json()

print(data['results'][0]['geometry']['location'])

以上代码将查询位于加利福尼亚州山景城的谷歌总部的经纬度,并打印出响应中的位置信息。您可以将地址更改为您想要解析的其他地址。请注意,你需要在Google Cloud Platform上注册并获取API密钥才能使用服务。

用Python解析经纬度地址

原文地址: http://www.cveoy.top/t/topic/tY5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录