怎么把<Cell 'Sheet'.A2>变成只有2?

How can turn <Cell 'Sheet'.A2> to only 2?

我对 openpyxl 有疑问。我的代码正在运行,但我不知道如何将值保存到 excel

我的密码是

def get_title(link):
    global list2
    driver = create_driver()
    driver.get(link)
    source = BeautifulSoup(driver.page_source, "lxml")
    title = source.select_one("title").text
    print(f"{link}: '{title}'")
    
    for row in ws.rows:
        if row[0].value == link:
            print(row)
            # ws.cell(row=???, column=2).value = title
            # wb.save("site.xlsx")

并打印出来

https://www.google.com/search?q=2&oq=2&aqs=chrome..69i57j69i59l2j0i271l2j69i60l2j69i61.623j0j1&sourceid=chrome&ie=UTF-8: '2 - Google search'
(<Cell 'Sheet'.A2>, <Cell 'Sheet'.B2>)
https://www.google.com/search?q=6&oq=6&aqs=chrome..69i57j0i271l3j69i60l3.3687j0j1&sourceid=chrome&ie=UTF-8: '6 - Google search'
(<Cell 'Sheet'.A1>, <Cell 'Sheet'.B1>)

我想做的是将标题保存到 excel 中的 B 列,但我不知道该怎么做

            for row in ws.iter_rows(0):
                for cell in row:
                    if cell.value == "test":
                        ws.cell(row=cell.row, column=2).value = "test"
                        wb.save("test.xlsx")

这个解决了我的问题