赞
踩
mport requests
import json
import re
import numpy as np
import pandas as pd
#做数据预处理,将数据调整为xx省xx市xx
df=pd.read_excel('嘉定.xlsx')
place=df['设备描述']
place1=[]
for i in place:
place1.append('上海市嘉定区安亭镇'+i)
#利用百度api获取地区的经纬度
AK = 'PmbFA5jwHSpwMRkumX6CpAtUWGqusswc'
jingdu=[]
weidu=[]
zhi=[]
for address in place1:
url = 'http://api.map.baidu.com/geocoding/v3/?address={}&output=json&ak={}&callback=showLocation'.format(address,AK)
res = requests.get(url)
print(res.text)
results = json.loads(re.findall(r'
print('\n')
jingdu.append(results['result']['location']['lng'])
weidu.append(results['result']['location']['lat'])
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。