写csv文件函数:csv_write()
    2021-12-13
  
描述

  csv_write() csv写入函数
  csv_write() 接收三个参数,第一个参数为输出的文件路径,第二个参数为表头,第三个参数为每行内容

语法

  以下是 csv_write() 的语法:
csv_write(path, headers, rows)

参数

  ● path [str]:文件路径,带csv后缀。
  ● headers [list]:表头,例:['编号', '课程', '讲师']。
  ● rows [list]:每行数据,例:[(1, 'Python', 'fighter.Lu'),(2, 'C#', 'fighter.Lu'),(3, '.Net', 'fighter.Lu')]。

返回值

  无返回值

实例

  以下展示了使用 csv_write() 的实例:   
from kyger.common import csv_write
headers = ['编号', '课程', '讲师']
rows = [(1, 'Python', 'fighter.Lu'), (2, 'C#', 'fighter.Lu'), (3, '.Net', 'fighter.Lu')]
csv_write('test.csv', headers, rows)

  以上实例运行后输出的结果为:
  写csv文件.png

适应版本

  v1.0.1