- 积分
- 617
- 金钱
- 488
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
高级会员
- 积分
- 617
- 金钱
- 488
- HASS币
- 0
|
发表于 2024-7-4 14:16:22
|
显示全部楼层
gpt大法就好了,代码如下
import requests
def get_formatted_address(ak, latitude, longitude):
url = "http://api.map.baidu.com/reverse_geocoding/v3/"
params = {
'ak': ak,
'output': 'json',
'coordtype': 'wgs84ll',
'location': f'{latitude},{longitude}'
}
response = requests.get(url, params=params)
if response.status_code == 200:
data = response.json()
if data.get('status') == 0:
return data['result']['formatted_address']
return None
ak = 'TwvTSt10wfCiU8G8BFMZVK5mTQFxb6sX'
latitude = 39.9118
longitude = 116.4200
address = get_formatted_address(ak, latitude, longitude)
print(address) |
|