将列表放入字符串中

2024-10-03 09:14:30 发布

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

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']

我怎样才能把这个串起来。加入是一个

谢谢


Tags: csvthehomedataoscolumnopendocuments
1条回答
网友
1楼 · 发布于 2024-10-03 09:14:30

how can I get this into a string. Join is one..

只需使用'whateveryouwanthere'.join(data)。 您已经提到了join方法,如果您不想要一个涉及join的解决方案,您需要解释这里的问题是什么

相关问题 更多 >