尝试这个:
from geopy.geoprers import Nominatimfrom geopy.exc import GeoprerTimedOutmy_address = '1600 Pennsylvania Avenue NW Washington, DC 20500'geolocator = Nominatim()try: location = geolocator.geopre(my_address) print(location.latitude, location.longitude)except GeoprerTimedOut as e: print("Error: geopre failed on input %s with message %s"%(my_address, e.message))
你还可以考虑增加对地理定位器的地理编码调用的超时时间。在我的示例中,它将类似于:
location = geolocator.geopre(my_address, timeout=10)
要么
location = geolocator.geopre(my_address, timeout=None)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)