TG-PlatformPlus/NewInstructionModel.py

12 lines
407 B
Python

import csv
import time
array1 = [1, 2, 3, 4] # 第一列数据
array2 = ['A', 'B', 'C', 'D'] # 第二列数据
# with open('output.csv', 'w', newline='') as f:
with open(f'datas/data{time.strftime("%Y%m%d%H%M%S")}.csv', 'w', newline='') as f:
writer = csv.writer(f)
# 写入表头
writer.writerow(['Column1', 'Column2'])
# 合并数据并写入
writer.writerows(zip(array1, array2))