1 頁 (共 1 頁)

[python] 建立CSV

發表於 : 2022-01-27, 11:17
Lexaul
參考資料:https://blog.gtwang.org/programming/pyt ... -tutorial/

寫入二維表格

代碼: 選擇全部

import csv

# 二維表格
table = [
    ['姓名', '身高', '體重'],
    ['令狐沖', 175, 60],
    ['岳靈珊', 165, 57]
]

with open('output.csv', 'w', newline='') as csvfile:
  writer = csv.writer(csvfile)

  # 寫入二維表格
  writer.writerows(table)