我怎样才能把我的产出放在桌子上?
from prettytable import PrettyTable
import sqlite3
x = PrettyTable(["URL"])
x.padding_width = 1
con = sqlite3.connect('C:\\Users\\joey\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History')
cursor = con.cursor()
d = cursor.execute("SELECT URL FROM 'urls' ;")
for data in d:
x.add_row([data])
print(x)如何将代码的输出添加到表中?这段代码不起作用。这段文字下面的代码很好。但是,我如何才能在这个而不是"test"中获得输出。
x = PrettyTable(["URL"])
x.padding_width = 1
x.add_row(["test"])发布于 2015-06-11 11:57:08
游标在迭代时返回元组。因此,不要使用[data] (它将是包含元组的列表),而是将data本身传递给add_row
for data in cursor:
x.add_row(data)https://stackoverflow.com/questions/30780068
复制相似问题