Python 3.x 使用csv模块写入数据
with open(fileName,'w',newline='') as f:
self.fileNames = ['timestamp','elapsedtime']
writer = csv.DictWriter(f,fieldnames = self.fileNames)
for li in self.allData: #分行读取
writer.writerow({'timestamp':li[0],'elapsedtime':li[1]})#以字典格式写入