运行最后两行时,它会报告错误消息,如下所示:
File "<stdin>", line 32
SyntaxError: can't assign to literal
解决这个问题的方法是什么?
from geopy.geocoders import Nominatim
geolocator = Nominatim()
# location = geolocator.geocode("175 5th Avenue NYC")
# location = geolocator.geocode("berlin, germany")
location = geolocator.geocode("oxford street, london")
print(location.address)
print((location.latitude, location.longitude))
import pandas
df = pandas.read_csv("city5.csv")
# print(df)
import io
import sys
import urllib.request
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') #改变标准输出的默认编码
res=urllib.request.urlopen('http://www.baidu.com')
htmlBytes=res.read()
# print(htmlBytes.decode('utf-8'))
df["Conca"]=df["city"]+", "+df["country"]
# print(df)
df["Coordinates"]=df["Conca"].apply(geolocator.geocode)
print(df)
print(df.columns)
print(df.Coordinates)
print(df.Coordinates[0].latitude)
df=["Ycor"]=df["Coordinates"].apply(lambda x: x.latitude if x != None else None)
print(df)
答案 0 :(得分:0)
=
你还有一个额外的df["Ycor"]=df["Coordinates"].apply(lambda x: x.latitude if x != None else None)
。我确定你的意思是:
{{1}}