我是 python 的初学者,我正在尝试将查询结果打印到管道分隔文件。我怎样才能修改这个脚本来做到这一点?
import cx_Oracle
import csv
connection = cx_Oracle.connect("blah blah blah connection stuff")
cursor = connection.cursor()
cursor.execute("select column1, column2 from schema.table")
result=cursor.fetchall()
c = csv.writer(open("C:\mystuff\output.csv","wb"))
c.writerow(result)
现在它打印出来像这样 "(10001965, '0828442C00548')","(10001985, '0696230C35242')","(10001986, 'C41251')"
我希望它在行尾打印管道分隔和新行。谢谢你的帮助!10001965|0828442C00548\n 10001985|0696230C35242\n 10001986|C41251\n