在运行最后两行时,它会报告一条错误消息,如下所示:
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)
你有一个额外的
=
。我相信你的意思是:相关问题 更多 >
编程相关推荐