获取一个字符串列表

时间:2014-06-08 16:16:56

标签: python string list

filename = 'result'
column = 'Latitude'

os.system("wget http://earthquake.usgs.gov/earthquakes/feed/csv/1.0/hour")
#csv_data = csv.reader(downloaded_data)

file = csv.reader(open('/home/coperthought/Documents/hour' , 'rb'), delimiter='\t')

data = [] # This will contain our data

# Create a csv reader object to iterate through the file
reader = csv.reader( open( '/home/coperthought/Documents/hour' , 'rU'), delimiter=',', dialect='excel')

hrow = reader.next() # Get the top row
idx = hrow.index(column) # Find the column of the data you're looking for

for row in reader: # Iterate the remaining rows
    data.append( row[idx] )


os.remove ( '/home/coperthought/Documents/hour')
print data

然后数据

['63.190', '63.730', '59.935', '38.805', '61.416', '63.213']

我怎样才能把它变成一个字符串。加入是一个..

感谢

1 个答案:

答案 0 :(得分:0)

  

我怎样才能把它变成一个字符串。加入是一个..

只需使用'whateveryouwanthere'.join(data)即可。 您已经提到过join方法,如果您不想要涉及join的解决方案,则需要解释这里的问题。