python3根据地址批量获取百度地图经纬度

python3代码如下:

import requests
import time
def get_mercator(addr):
    url= 'http://api.map.baidu.com/geocoder/v2/?address=%s&output=json&ak=************************&callback=showLocation'%(addr)
    response = requests.get(url)
    return response.text
def TXTRead_Writeline(src,dest):
    ms = open(src,encoding='utf-8')
    for line in ms.readlines():
        with open(dest,"a",encoding='utf-8') as mon:
            loc=get_mercator(line)
            mon.write(loc)
            mon.write("\n")
            time.sleep(1)
TXTRead_Writeline("D:\Data\\test.txt","D:\Data\\result.txt")

  

转载于:https://www.cnblogs.com/davidwang456/p/9679365.html

你可能感兴趣的:(python3根据地址批量获取百度地图经纬度)