location = geolocator.geocode(" ".join(address.values()))
if location.longitude is not None:
node['pos'] = [location.longitude, location.latitude]
不要理解我仍然会收到此错误:
File "/home/easypc/Documents/Udacity_nano_degree/Data_Wrangling/audit_vilnius.py", line 167, in shape_element
if location.longitude is not None:
AttributeError: 'NoneType' object has no attribute 'longitude'
答案 0 :(得分:7)
location
变量本身就是None
,也可以对此进行测试:
if location is not None and location.longitude is not None:
或者更简单地说:
if location: