网上买了个aliyun api, 给出的示例代码是python2的,不能用,所以只能写一个基于python3的代码.
import requests
import urllib.parse
host = 'http://geo.market.alicloudapi.com'
path = '/v3/geocode/geo'
appcode = '1111111111111111111111' # 你的app code
address = '北京市朝阳区方恒国际中心'
encoded_address = urllib.parse.quote(address)
city = 'beijing'
encoded_city = urllib.parse.quote(city)
query = 'address=' + encoded_address + '&batch=false&callback=callback&city='+ encoded_city +'&output=JSON'
url = host + path + '?' + query
response = requests.get(url, headers={"Authorization": "APPCODE " + appcode})
print(response.status_code) # 展示状态码
print(response.text) # 展示content
这是一个根据地理信息获取经纬度的代码。