用python代码将数据写入csv文件,但生成的csv文件没两行数据之间有一个空行,如下图所示:
在open函数中添加newline='',如以下代码所示,即可解决这一问题。
with open(r"C:\Users\xxx\Desktop\DRCD-master\DRCD_test.csv",'w',encoding='utf-8') as f:
# 加入newline=''
with open(r"C:\Users\xxx\Desktop\DRCD-master\DRCD_test.csv",'w',encoding='utf-8',newline='') as f:
结果如下图所示: