写入:write.py
#!/usr/bin/python
# -*- coding:utf-8 -*-
import csv
print("Test for csv write")
p1 = ['kevin',20]
p2 = ['jason', 16]
p3 = ['frank', 35]
out = open("1.csv",'a',newline='')
csv_write = csv.writer(out ,dialect='excel')
csv_write.writerow(p1)
csv_write.writerow(p2)
csv_write.writerow(p3)
print("write over")
读取 read.py
#!/usr/bin/python
# -*- coding:utf-8 -*-
import csv
csvf = csv.reader(open("1.csv",'r'))
for stu in csvf:
print(stu)