看板 Python 關於我們 聯絡資訊
小弟是新手,想寫入資料 查詢了CSV的用法 import csv data = [ [' 101/01/31', '5,486,734,180', '162,361,181,834', '1,283,951', '7,517.08', '109.67'], [' 101/01/13', '3,497,838,901', '99,286,437,370', '819,762', '7,181.54', '1'], ] f = open("stock.csv","w") w = csv.writer(f) w.writerows(data) f.close() 這是在網路上看到的,執行後資料會放成row 如果我想要把DATA放直的(也就是說一個List[] 資料放一個column 要怎麼使用呢><?) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.124.201.37
tiefblau:zip(*data) 03/18 20:18
lingze:請問樓上大大ZIP怎麼轉換@@? 03/18 20:23
lingze:辦到了~~謝謝大大 03/18 20:25
tiefblau:data = zip(*data) 或是直接w.writerows(zip(*data)) 03/18 20:28
lingze:謝謝各位大大:D 03/18 20:28
tiefblau:恩沒事~ 03/18 20:28
tiefblau:可惡 一直趁我打字的時候回覆我啊XDD 03/18 20:29
lingze:XD 03/18 20:31