赞
踩
python读写csv文件,使用csv.reader()方法及csv.writer()方法 import csv with open(r"C:\郑宏宇\python_learn\c.csv","r") as f: a_csv = csv.reader(f) for row in a_csv: print(row) with open(r"C:\郑宏宇\python_learn\c.csv","w")as f: b_csv = csv.writer(f) b_csv.writerow(["id","姓名","年龄"]) #writerow按行写入 b_csv.writerow(["1001", "郝佳", "18"]) c = [["1002","明明","5"],["1003","东东","4"]] b_csv.writerows(c)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。