From f1a843de76b1054315162a01df3f6c7bcccd2e98 Mon Sep 17 00:00:00 2001 From: Radar_Lei Date: Sat, 23 Dec 2017 22:17:48 +0800 Subject: [PATCH 1/2] urllib urllib has been split up in Python 3. The urllib.urlencode() function is now urllib.parse.urlencode(), and the urllib.urlopen() function is now urllib.request.urlopen(). --- coordTransform_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coordTransform_utils.py b/coordTransform_utils.py index 69fa3bf..6800f33 100644 --- a/coordTransform_utils.py +++ b/coordTransform_utils.py @@ -23,8 +23,8 @@ def geocode(self, address): 'key': self.api_key, 'city': '全国', 'address': address} - geocoding = urllib.urlencode(geocoding) - ret = urllib.urlopen("%s?%s" % ("http://restapi.amap.com/v3/geocode/geo", geocoding)) + geocoding = urllib.parse.urlencode(geocoding) + ret = urllib.request.urlopen("%s?%s" % ("http://restapi.amap.com/v3/geocode/geo", geocoding)) if ret.getcode() == 200: res = ret.read() @@ -170,6 +170,6 @@ def out_of_china(lng, lat): result5 = bd09_to_wgs84(lng, lat) result6 = wgs84_to_bd09(lng, lat) - g = Geocoding('API_KEY') # 这里填写你的高德api的key + g = Geocoding('67e5dbb66e433773c13b76837a268e45') # 这里填写你的高德api的key result7 = g.geocode('北京市朝阳区朝阳公园') - print result1, result2, result3, result4, result5, result6, result7 + print (result1, result2, result3, result4, result5, result6, result7) From bae6c6af8b951c579d9c25ce1ebb77088386f648 Mon Sep 17 00:00:00 2001 From: Radar_Lei Date: Sat, 23 Dec 2017 22:22:38 +0800 Subject: [PATCH 2/2] urllib urllib has been split up in Python 3. The urllib.urlencode() function is now urllib.parse.urlencode(), and the urllib.urlopen() function is now urllib.request.urlopen(). --- coordTransform_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coordTransform_utils.py b/coordTransform_utils.py index 6800f33..8cd365b 100644 --- a/coordTransform_utils.py +++ b/coordTransform_utils.py @@ -170,6 +170,6 @@ def out_of_china(lng, lat): result5 = bd09_to_wgs84(lng, lat) result6 = wgs84_to_bd09(lng, lat) - g = Geocoding('67e5dbb66e433773c13b76837a268e45') # 这里填写你的高德api的key + g = Geocoding('key') # 这里填写你的高德api的key result7 = g.geocode('北京市朝阳区朝阳公园') print (result1, result2, result3, result4, result5, result6, result7)