Python调用百度根据经纬度查询地址

def locatebyLatLng(lat, lng, pois=0):
    '''
    根据经纬度查询地址
    '''
    items = {'location': str(lat) + ',' + str(lng), 'ak': '你自己申请的百度ak', 'output': 'json'}
    res = requests.get('http://api.map.baidu.com/geocoder/v2/', params=items)
    result = res.json()
    print(result)
    print('--------------------------------------------')
    #result = result['result']['formatted_address'] + ',' + result['result']['sematic_description']
    result = result['result']['addressComponent']['city']
    return result

你可能感兴趣的:(Python调用百度根据经纬度查询地址)