安装
pip install pandas
示例
# -*- coding: utf-8 -*- import pandas as pd lst = [ { "name": "Tom", "age": 23, "sex": 1, }, { "name": "Jack", "age": 24, "sex": 0, }, { "name": "Steve", "age": 25, "sex": 1, }, ] df = pd.DataFrame(lst) df.to_csv('./student.csv', columns=['name', 'age', 'sex'], header=['姓名', '年龄', '性别'], index_label='序号', )
用到的参数
columns 设置导出列 header 导出列标题 index_label 导出序号列标题
导出展示