python Python的Geo工具

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Python的Geo工具相关的知识,希望对你有一定的参考价值。

import requests


def geocode(address):
    data = requests.get('http://geocode-maps.yandex.ru/1.x/', params={
        'geocode': address,
        'format': 'json',
    }).json()

    try:
        point = data['response']['GeoObjectCollection']['featureMember'][0] \
                    ['GeoObject']['Point']['pos']
    except KeyError:
        return None

    return point.split()

以上是关于python Python的Geo工具的主要内容,如果未能解决你的问题,请参考以下文章