# 如何读写csv数据
import csv
# 读
rf = open('test.csv', 'r', encoding='gbk')
reader = csv.reader(rf)
print(next(reader))
# for row in reader: print(row)
# 写
wf = open('test_copy.csv', 'w', encoding='gbk')
writer = csv.writer(wf)
for row in reader: writer.writerow(row)
wf.flush()
# 如何读写csv数据
import csv
# 读
rf = open('test.csv', 'r', encoding='gbk')
reader = csv.reader(rf)
print(next(reader))
# for row in reader: print(row)
# 写
wf = open('test_copy.csv', 'w', encoding='gbk')
writer = csv.writer(wf)
for row in reader: writer.writerow(row)
wf.flush()
# 如何读写csv数据 import csv # 读 rf = open('test.csv', 'r', encoding='gbk') reader = csv.reader(rf) print(next(reader)) # for row in reader: print(row) # 写 wf = open('test_copy.csv', 'w', encoding='gbk') writer = csv.writer(wf) for row in reader: writer.writerow(row) wf.flush()