下面是我當前的代碼。在列表中使座標對分開的值
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)
等所有座標對。
有沒有什麼辦法讓座標輸出到我想要的輸出?
感謝@Elazar代碼的工作非常適合我需要的東西,但是我也沒必要拉鍊經度和緯度,但感謝您的幫助。 – user2423678