私は python モジュール googlemaps 1.0.2 を使用していますが、ユーザーが不明なアドレスを入力した場合、try ステートメントを使用できません。
表示されるエラー メッセージは次のようになります。
GoogleMapsError: Error 602: G_GEO_UNKNOWN_ADDRESS
私のメソッドは次のようになります (API キーなし):
from googlemaps import GoogleMaps
def get_distance(address, destination):
try:
gmaps = GoogleMaps(api_key)
directions = gmaps.directions(address,destination)
distance = directions['Directions']['Distance']['meters']/1600.0
return distance
except ???:
私が試してみました:
except GoogleMapsError:
except 'GoogleMapsError: Error 602: G_GEO_UNKNOWN_ADDRESS'
ありがとう