【发布时间】:2020-08-07 21:00:49
【问题描述】:
我正在尝试使用 writerow,使用 python 的 sqlite3 包将 fetchall 结果写入 csv 文件
import sqlite3
import time,csv
s=time.time()
con = sqlite3.connect("dreamtool.db")
cur = con.cursor()
cur.execute("select * from result3")
result = cur.fetchall()
c = csv.writer(open("temp.csv","wb"))
c.writerow(result)
e=time.time()
con.close()
print(e-s)
我收到错误,因为需要类似字节的对象,而不是 'str'
【问题讨论】: