ValueError:字典更新序列元素#0的长度为1;使用python sqlite3需要2

时间:2020-04-26 17:47:59

标签: python-3.x sqlite valueerror

我正在创建一个基本数据库和一个菜单,以使用python浏览它。 向我请求在新窗口中显示的记录时,新窗口中显示的所有内容都很好。

# Creating new window
response = messagebox.askyesno('Records', 'which records would you like to view?',)

    if response == 1:
    Records = Tk()
    Records.title('Employee Records')
    Records.geometry('350x200')

    # Connecting to database
    conn = sqlite3.connect('expiration_book.db')
    c = conn.cursor()

    c.execute("SELECT *, oid FROM expire_book")
    records = c.fetchall()

    print_records = ''
    for record in records:
        print_records += str(record) + "\n"

    query_label = Label(Records, text=print_records)
    query_label.grid(row=0, column=0)

    conn.commit()
    conn.close()

但是,当我尝试将框架添加到该新窗口并在其中显示记录时,出现以下错误:

# Creating new window
response = messagebox.askyesno('Records', 'which records would you like to view?',)

    if response == 1:
    Records = Tk()
    Records.title('Employee Records')
    Records.geometry('350x200')

    # Creating a frame
    employee_frame = LabelFrame(Records, "Employee Records", padx=10, pady=10)
    employee_frame.grid(row=0, column=0)

    # Connecting to database
    conn = sqlite3.connect('expiration_book.db')
    c = conn.cursor()

    c.execute("SELECT *, oid FROM expire_book")
    records = c.fetchall()

    print_records = ''
    for record in records:
        print_records += str(record) + "\n"

    query_label = Label(employee_frame, text=print_records)
    query_label.grid(row=0, column=0)

    conn.commit()
    conn.close()

“ ValueError:字典更新序列元素#0的长度为1;必须为2”

我在任何地方看到的内容都与字典有关,但是它在没有框架的情况下也可以使用,所以我不确定如何针对框架格式进行调整。

0 个答案:

没有答案