[python] 建立CSV

回覆文章
Lexaul
文章: 231
註冊時間: 2019-10-18, 14:28

[python] 建立CSV

文章 Lexaul » 2022-01-27, 11:17

參考資料: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)
[email protected]
github.com/Lexaul

回覆文章