###寒假第一次美赛
##地点经纬度获取
import json
import requests
from urllib.request import urlopen, quote
address = '焦作市云台山'
url= 'http://api.map.baidu.com/geocoder?output=json&key=f247cdb592eb43ebac6ccd27f796e2d2&address='+str(address)
response = requests.get(url)
#print(response.json())
answer = response.json()
lon = float(answer['result']['location']['lng'])
lat = float(answer['result']['location']['lat'])
print(address,lat,lon)
def get_lonlat(id):
address = id
url= 'http://api.map.baidu.com/geocoder?output=json&key=f247cdb592eb43ebac6ccd27f796e2d2&address='+str(address)
response = requests.get(url)
#print(response.json())
answer = response.json()
lon = float(answer['result']['location']['lng'])
lat = float(answer['result']['location']['lat'])
result=[address,lat,lon]
return result
id1=get_lonlat('郑州')
id2=get_lonlat('杭州')
地点经纬度获取
最新推荐文章于 2021-07-23 15:49:41 发布