示例
import csv
with open('t.csv', mode='r', encoding='utf-8') as f:
reader_obj = csv.reader(f) # 通过reader将文件对象中的数据全部读取出来
for line in reader_obj:
print(line)
with open('t.csv', mode='w', encoding='utf-8') as f:
writer_obj = csv.writer(f) # 通过csv的writer生成写对象
writer_obj.writerow([3, '4']) # 通过writerow将数据写入,一行
writer_obj.writerows([[1,2], [3,4]]) # 通过writerows将二维数组中的每个列表当作一行写入