python - 如何在 Python 中将 int 与字符串连接起来?
问题描述
我想将 for 循环的 i 与 xpath 连接,但它给了我这个错误“TypeError: can only concatenate str (not "int") to str”。我该如何解决这个问题?
guardaremail = 'asd@asd'
teste = self.driver.find_element_by_xpath("//*[text()='" + guardaremail + "']")
tabela = self.driver.find_elements_by_xpath("/html/body/div[1]/div/table/tbody/tr")
for i in range(1, len(tabela), 1):
#verifica if tr = email
emailteste = self.driver.find_element_by_xpath("/html/body/div[1]/div/table/tbody/tr[" + i + "]/td[2]")
botaoteste = self.driver.find_element_by_xpath("/html/body/div[1]/div/table/tbody/tr[" + i + "]/button[1]")
#carrega no tr com id = "ui positive button"
if emailteste == teste:
botaoteste.click()
解决方案
采用"tr"+str(i)+"/td
推荐阅读
- django - `graphene_django` 的`op_name` 参数
- html - 提交按钮不适用于 Android,但适用于 PC 和 iPhone
- azure - 如何为 Azure kubernetes LoadBalancer 使用静态外部 IP?
- flutter - Flutter - 如何动态PageView?
- python - 连接存储在一个对象中的多个列表
- html - 如何在 CSS 中正确寻址
- android - 浮动按钮和导航抽屉 Kotlin 导致应用程序崩溃
- node.js - 一对多关系
- cobol - 如何搜索一个简单的表?
- spring - 从正在运行的应用程序获取服务器端口值