我有这种数据,我想在Python中提取纬度和经度。
col[index]=
52.420223333,-1.904525
52.420221667,-1.904531667
52.420221667,-1.904536667
52.42022,-1.904545
52.420218333,-1.904553333
52.420216667,-1.904556667
我知道如何在PHP中执行此操作,但不确定如何在Python中实现它:
sscanf($string, '"(%f, %f)"', $lat, $lng);
编辑: 此代码运行并输出上面的坐标
for index in range(len(col)):
print col[index]
在for循环中,是否可以获取lat和long数据。例如对于第一次迭代,lat = 52.420223333和lon = -1.904525。
答案 0 :(得分:3)
for index in range(len(col)):
lat, lon = col[index].split(",")
print "lat=%s, lon=%s" % (lat, lon)