反向地理代码,读取.CSV文件和类型错误:需要浮点

2024-05-28 23:04:54 发布

您现在位置:Python中文网/ 问答频道 /正文

修正:将float()添加到coordinates 1和coordinates 2:

my_location = gmaps.reverse_geocode(float(coordinates1), float(coordinates2))

我试着把长坐标转换成地址。我有一个带有坐标的.CSV文件,我不知道我的代码是否可以读取它,或者它是否有其他错误。 这是我的代码:

^{pr2}$

错误消息:

Traceback (most recent call last):
  File "C:/../latlongs.py", line 22, in <module>
    my_location = gmaps.reverse_geocode(coordinates1,coordinates2)

  File "C:\..\pygeocoder.py", line 155, in reverse_geocode
    'latlng':   "%f,%f" % (lat, lng),
['69.9687376', '23.2715496']
TypeError: a float is required

Tags: 代码inpymy错误linelocationfloat

热门问题