写入csv文件发现每写一行都多出一行空白
# 原代码
import csv
a1 = ['ID','姓名','年龄']
a2 = ['001','小七',17]
a3 = ['002','小八',18]
with open('test_csv.csv','w') as f:
writer = csv.writer(f)
writer.writerows([a1,a2,a3])

修改成下面代码即可
import csv
a1 = ['ID','姓名','年龄']
a2 = ['001','小七',17]
a3 = ['002','小八',18]
with open('test_csv.csv','w',newline='') as f: # 加了一个newline参数
writer = csv.writer(f)
writer.writerows([a1,a2,a3])
