[英]AttributeError: 'list' object has no attribute 'replace' Selenium Python
I am getting an attribute error with the replace() function我收到 replace() function 的属性错误
AttributeError: 'list' object has no attribute 'replace'
I am trying to replace [
and '
with an empty string.我正在尝试将
[
和'
替换为空字符串。
owner_address = response.xpath('XPATH Expression').getall().replace("[", "").replace("'", "")
owner_address_region = response.xpath('XPATH Expression').getall().replace("[", "").replace("'", "")
Output: Output:
To:至:
The return type of getall()
is a list and you can join list elements using join
. getall()
的返回类型是一个列表,您可以使用join
连接列表元素。
A working example would be "".join(response.xpath('XPATH Expression').getall())
一个工作示例是
"".join(response.xpath('XPATH Expression').getall())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.