python 寫入CSV檔案
import csv # 定義要寫入CSV檔案的資料 data = [ ['Name', 'Age', 'City'], ['Alice', '25', 'New York'], ['Bob', '30', 'San Francisco'], # ... ] # 開啟CSV檔案以寫入資料 with open('output.csv', 'w', newline='') as file: writer = csv.writer(file) # 寫入CSV檔案的每一行 for row in data: writer.writerow(row)
#########################