问题描述
此代码有问题。运行它之后,我的place_id是ChIJ8wUUXmY8uUcRB0W-usk4yB。 我应该产生一个place_id,前七个字符为ChIJUaC ... 我一直在努力寻找与我的代码有关的问题。 给了我一个示例位置和结果。根据我的代码生成的place_id与示例place_id完全匹配。有人可以帮助我了解问题所在吗? 这是我的代码:
import urllib.request,urllib.parse,urllib.error
import json
import SSL
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
serviceurl = 'http://py4e-data.dr-chuck.net/geojson?'
while True:
##User input
address = input('Enter location: ')
##Presss enter to break out of the loop
if len(address) < 1: break
parms = dict()
parms['address'] = address
parms['key'] = 42
try:
##Establish connection
url = serviceurl + urllib.parse.urlencode(parms)
print('Retrieving',url)
_connection = urllib.request.urlopen(url,context=ctx)
##Access the JSON file
data = _connection.read().decode()
print('Retrieved',len(data),'characters')
info = json.loads(data)
except:
info = None
if not info or 'status' not in info or info['status'] != 'OK':
print('==== Failure To Retrieve ====')
print(data)
continue
place_id = info["results"][0]["place_id"]
print("PLACE ID: ",place_id)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)