我想寫一個數組的值到Python中的.csv文件。但是,當我在Excel中打開文件時,數據顯示在一行中。我想有一列,每個成員的數組是一行。寫入數組到csv python(一列)
陣列 「testLabels」 的形式爲:
array(['deer', 'airplane', 'dog', ..., 'frog', 'cat', 'truck'],
dtype='<S10')
我使用寫入CSV的代碼是:
import csv
resultFile = open("/filepath",'wb')
wr = csv.writer(resultFile)
wr.writerows([testLabels])
任何幫助,將不勝感激。
問題長期以來一直回答關於蟒蛇方的建議。但是,在MS Excel中使用函數會更容易:只需使用[text-to-columns函數](http://www.excel-easy.com/examples/text-to-columns.html)。 – MERose