【发布时间】:2018-03-12 05:56:04
【问题描述】:
我在 python 中有这段代码
from googlemaps import Client
apiKey = 'xxxx'
lat = input("Please enter latitude: ")
lng = input("Please enter longitude: ")
maps = Client(apiKey)
reverseGeo = maps.reverse_geocode(lat,lng)
address = reverseGeo['Placemark'][0]['address']
print(address)
每当我尝试运行并输入 lat 和 lng 值时,都会发生此错误:
Please enter latitude: 5
Please enter longitude: 10
Traceback (most recent call last):
File "D:/Programs/github/mobile_application_development/Ex 1/part 1/main.py", line 6, in <module>
reverseGeo = maps.reverse_geocode(lat,lng)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 356, in wrapper
result = func(*args, **kwargs)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\geocoding.py", line 109, in reverse_geocode
return client._request("/maps/api/geocode/json", params)["results"]
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 253, in _request
result = self._get_body(response)
File "C:\Users\Truong Dang\AppData\Roaming\Python\Python34\site-packages\googlemaps\client.py", line 267, in _get_body
raise googlemaps.exceptions.HTTPError(response.status_code)
googlemaps.exceptions.HTTPError: HTTP Error: 400
我可以问一个原因以及如何解决它吗?
【问题讨论】:
标签: python python-3.x rest google-maps reverse-geocoding