Python 写入CSV-创建多个空行

Python 写入CSV-创建多个空行,python,csv,cursor,blank-line,Python,Csv,Cursor,Blank Line,我是Python新手,我尝试将数据从SQL插入到CSV。 我有以下代码: sql = cursor.execute("SELECT field_a, field_b, field_c FROM TableA LIMIT 500") result=cursor.fetchall() fp = open('dataset.csv', 'w') myFile = csv.writer(fp) myFile.writerows(result) fp.close()

我是Python新手,我尝试将数据从SQL插入到CSV。 我有以下代码:

sql = cursor.execute("SELECT field_a, field_b, field_c FROM TableA LIMIT 500")
    result=cursor.fetchall()
    fp = open('dataset.csv', 'w')
    myFile = csv.writer(fp)
    myFile.writerows(result)
    fp.close()
但是当我看到创建的CSV时,我有多个空行。我做错了什么?

Python 2.7:

fp = open('dataset.csv', 'wb')
Python3.x:

fp = open('dataset.csv', 'w', newline='')

在代码中,从不使用
结果。