Python 读写.csv文件
作者:互联网
写入: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)
标签:writerow,Python,读写,coding,write,print,csv,open 来源: https://blog.csdn.net/skyblue976/article/details/120613866