以下是我当前的代码。
import csv
def function():
latitude = []
longitude = []
with open('data.csv', 'rU') as input: #
dL= list(csv.reader(input))
sL = [row[4] for row in dL[1:]]
longitude.append(sL)
sL1 = [row[3] for row in dL[1:]]
latitude.append(sL1)
print latitude
print longitude
print
for i in range(0, len(latitude)):
print "Co-ordinates (" + str(latitude[i]) + "," + str(longitude[i]) + ")"
function()
对,所以我的输出产生了这个
[['-20.71', '-20.73', '-20.88', '-20.78', '-20.76', '-20.68', '-20.95', '-21.06', '-21.05', '-20.9']]
[['116.77', '116.75', '116.67', '117.15', '117.16', '117.19', '117.37', '117.44', '116.26', '117.64']]
Co-ordinates (['-20.71', '-20.73', '-20.88', '-20.78', '-20.76', '-20.68', '-20.95', '-21.06', '-21.05', '-20.9'],['116.77', '116.75', '116.67', '117.15', '117.16', '117.19', '117.37', '117.44', '116.26', '117.64'])
这显示了我想要生成的列表。
我想要做的是产生一个看起来像这样的输出
Co-ordinates (-20.71,116.77)
Co-ordinates (-20.73, 116.75)
对于所有坐标对,依此类推。
有什么方法可以得到我想要的输出坐标的输出吗?