如何格式化xpath里面的数据

__VIEW_ORDERDETAIL_BTN = (By.XPATH,’//[contains(text(),“220623200649250”)]/…/…//[@class=“order_detail”]’)

需要将220623200649250换成变量,这种应该如何格式化呢

a = 220623200649250
__VIEW_ORDERDETAIL_BTN = (By.XPATH,’//[contains(text(), a)]/…/…// [@class=“order_detail”]’)


没有进行替换额

a = 220623200649250
__VIEW_ORDERDETAIL_BTN = (By.XPATH,f'//[contains(text(),"{a}")]/…/…//[@class =“order_detail”]')
print(__VIEW_ORDERDETAIL_BTN)

成功解决,感谢

客气 :grin:

关闭