📜  将表格写入 CSV 文件 python 代码示例

📅  最后修改于: 2022-03-11 14:45:56.470000             🧑  作者: Mango

代码示例2
header = [re.sub(' +',' ',i[0][:-1].replace('\n', ' ')) for i in optionsTable[0]]

with open('test.csv', 'w') as fp:
   writer = csv.writer(fp, delimiter=',')
   writer.writerow(header)
   for row in optionsTable:
      writer.writerow([i[1] for i in row])

#Credit to https://stackoverflow.com/users/790387/burhan-khalid Burhan Khalid
#On StackOverflow.