【发布时间】:2021-05-01 18:58:19
【问题描述】:
我正在尝试从数据库中检索信息并以这种特定方式显示它:
名字:蝙蝠侠
价格:18 英镑
但我收到此错误:“TypeError: 'int' object is not subscriptable.”
我该如何解决这个问题?
c.execute("SELECT name, price FROM products WHERE id=02")
records = c.fetchone()
# print(records)
print_products = ''
for record in records:
print_products += 'Name:' + str(record[0]) + '\n' + 'Price: £' + str(record[1])
query_label = Label(frame, fg='darkblue', bg='darkgray', text=print_products)
query_label.pack()
【问题讨论】:
标签: python sqlite user-interface tkinter