关于基于访问选项卡的for循环的问题

2024-04-27 18:17:08 发布

您现在位置:Python中文网/ 问答频道 /正文

本质上应该发生的是从数据库表中获取一些包含id的信息。在数据库中找到input.text()元素之一作为ID之一的情况下,我希望它运行X,但会绕过并运行Y

`DBConnect = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=C:\\A\\B\\C;')
    DBSelect = DBConnect.cursor()
    DBSelect.execute("select * from ...)
    Row = DBSelect.fetchall()
    Update = False
    for field in Row:
        Appointment_ID = field[0]
        print(Appointment_ID)
        Selected_ID = self.ui.input.text()
        Selected_ID = str(Selected_ID)
        print(Selected_ID, "this is selected")
        print(Update)

        if Appointment_ID == Selected_ID:
            Update = True

    print(Update, "this is update")
    if Update == True: 
        run X
    else:
        run Y`

下面是当我输入141时在运行该代码时产生的打印输出,正如您所看到的,它不会产生Update=True输出

第139页, 141选择此选项, 假的, 140, 141选择此选项, 假的, 141, 141选择此选项, 假的, False这是更新


Tags: textid数据库falsetrueinput选项driver