Python Django中的Geopy:JSONDecodeError
我已在中学习了教程 这很好:Python Django中的Geopy:JSONDecodeError,python,django,simplejson,geopy,Python,Django,Simplejson,Geopy,我已在中学习了教程 这很好: g = geocoders.Google(resource='maps') 我想使用json作为输出格式,因为我想用javascript处理结果 但每次我使用: g = geocoders.Google(resource='maps', output_format='json') 我得到以下错误: Environment: Request Method: GET Request URL: http://localhost:8000/business/view/
g = geocoders.Google(resource='maps')
我想使用json作为输出格式,因为我想用javascript处理结果
但每次我使用:
g = geocoders.Google(resource='maps', output_format='json')
我得到以下错误:
Environment:
Request Method: GET
Request URL: http://localhost:8000/business/view/13/
Django Version: 1.2.1
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'registration',
'pley.business',
'pley.review',
'django.contrib.admin',
'django.contrib.webdesign']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "C:\django\pley\..\pley\business\views.py" in business_view
57. for place, (lat, lng) in g.geocode(string_location,exactly_one=False):
File "c:\python25\lib\site-packages\geopy-0.94-py2.5.egg\geopy\geocoders\google.py" in geocode
66. return self.geocode_url(url, exactly_one)
File "c:\python25\lib\site-packages\geopy-0.94-py2.5.egg\geopy\geocoders\google.py" in geocode_url
73. return dispatch(page, exactly_one)
File "c:\python25\lib\site-packages\geopy-0.94-py2.5.egg\geopy\geocoders\google.py" in parse_json
123. json = simplejson.loads(page)
File "C:\Python25\lib\site-packages\simplejson-2.1.1-py2.5-win32.egg\simplejson\__init__.py" in loads
384. return _default_decoder.decode(s)
File "C:\Python25\lib\site-packages\simplejson-2.1.1-py2.5-win32.egg\simplejson\decoder.py" in decode
402. obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python25\lib\site-packages\simplejson-2.1.1-py2.5-win32.egg\simplejson\decoder.py" in raw_decode
420. raise JSONDecodeError("No JSON object could be decoded", s, idx)
Exception Type: JSONDecodeError at /business/view/13/
Exception Value: No JSON object could be decoded: line 1 column 0 (char 0)
如有任何建议/答复,将不胜感激
谢谢 你读过geopy页面上的评论了吗 gregor.horvath的评论,9月11日, 2009年 要知道,虽然有 不同的输出格式参数 地理编码器,实际输出 地理编码函数的格式为 总是一样的: 位置(纬度、经度) 输出_格式仅指 来自地理编码器服务的输出 (谷歌等),而不是 地理编码功能 嗯,这是一个bug:将:resource='maps'更改为resource='maps/geo'很有效