【发布时间】:2016-06-15 20:40:10
【问题描述】:
我想确保获得正确城市的纬度和经度。例如,澳大利亚有悉尼,加拿大有悉尼。这很好用
for d in listofobjs:
location = geolocator.geocode(d['city'])
d2 = {
'username': d['username'],
'latitude': location.latitude,
'longitude': location.longitude
}
listofobjs2.append(d2)
但是如果我尝试这样的位置,我会得到一个错误
location = geolocator.geocode(d['city'],d['country'])
当我尝试从位置读取纬度时出现错误
AttributeError: 'list' object has no attribute 'latitude'
是否可以同时传递城市和国家来进行地理编码?
【问题讨论】: