【发布时间】:2021-11-02 05:24:29
【问题描述】:
我想查看组合框中的数据库列的内容。我知道这很容易,但我做不到。我刚开始使用 Python。我一定是弄得一团糟,出了点问题。我该怎么办?
请告诉我答案中的代码,既是因为我是 Python 新手,我可能不明白,而且因为这样我可以分配最佳答案。谢谢
更新了我的代码
import sqlite3
con = sqlite3.connect('folder db')
cursor = con.cursor()
def combo_city():
cursor.execute('SELECT City FROM Table1')
result=[row[0] for row in cursor]
return result
city=ttk.Combobox(window, width = 25)
city['value'] = combo_city()
city.place(x=13, y=80)
city.set("Select")
【问题讨论】:
标签: python sql python-3.x python-2.7 sqlite