0
curr = conn.cursor()
sql = """ select order# from Orders WHERE STATUS <> 'Shipped' and STATUS <> 'Not Found' and order# > '' """
curr.execute(sql)
row: List[Any] = curr.fetchall()
for x in row:
    searchInput = x
serchinput_textbox = driver.find_element_by_id("searchInput")
serchinput_textbox.send_keys(searchInput)
searchbutton = driver.find_element_by_id("searchButton")
searchbutton.click()

当我打印该行时,所有记录都在那里,但在 for 循环中它只使用最后一条记录。我不确定我是否正确创建了列表。

4

1 回答 1

0

您的for循环处理您的结果,除了将其分配给searchInput变量外,对每一行都不做任何事情。您可能想在 for 循环中添加一些代码来处理返回的每一行。现在,在循环完成后,您最终将得到的只是searchInput包含结果集中的最后一行。

编辑:尝试添加以下内容以查看您如何丢弃除最后一行之外的所有行:

for x in row:
    print("Here's a row to process:", x)  # Add this line
    searchInput = x
于 2021-09-16T22:05:27.257 回答