python中csv模块的操作

import csv

# 保存至csv文件

grade_list = [["A", "17", "90"],
              ["B", "17", "80"],
              ["C", "17", "70"]]
title_list = ["name", "year", "grade"]
with open("grade.csv", "w", newline='') as t:
    writer = csv.writer(t)
    writer.writerow(title_list)
    writer.writerows(grade_list)

你可能感兴趣的:(python中csv模块的操作)