Python CSV写入操作

#!/user/bin/env python3
# -*- coding: utf-8 -*-

import csv
with open("./test.csv",'w',encoding='gbk',newline='') as f:
    csv_writer=csv.writer(f)
    csv_writer.writerow(['shiyu41','18','男'])
    csv_writer.writerow(['x','18','女'])
    csv_writer.writerow(['l','18','男'])
    csv_writer.writerows([[0, 1, 2], [3, 4, 5], [6, 7, 8]])  # 写入多行writerows
    f.close()


上一篇:jmeter压测学习16-setUp线程组批量登录用户后保存token到本地.csv文件


下一篇:c# xml与dataset互转