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]})#以字典格式写入
posted @ 2017-01-05 16:56  wsy11  阅读(220)  评论(0编辑  收藏  举报