简体   繁体   English

AttributeError: 'list' object 没有属性 'replace' Selenium Python

[英]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:

['SYLVIA A BROWN', '395 BEELAND DR'] ['SYLVIA A BROWN','395 BEELAND DR']

To:至:

SYLVIA A BROWN, 395 BEELAND DR SYLVIA A BROWN,395 比兰德博士

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.

相关问题 AttributeError: 'list' object 没有属性 'replace' Python - AttributeError: 'list' object has no attribute 'replace' Python AttributeError: 'list' object 没有属性 'isDisplayed' Python Selenium - AttributeError: 'list' object has no attribute 'isDisplayed' Python Selenium AttributeError: 'list' 对象没有使用 Selenium 和 Python 的属性 'click' - AttributeError: 'list' object has no attribute 'click' using Selenium and Python python AttributeError:“ NoneType”对象在列表中没有属性“ replace” - python AttributeError: 'NoneType' object has no attribute 'replace' in list Selenium AttributeError: 'list' object 没有属性 'text' - Selenium AttributeError: 'list' object has no attribute 'text' AttributeError:'list'对象没有属性'replace' - AttributeError: 'list' object has no attribute 'replace' AttributeError: 'list' 对象没有属性 'replace' "fasttext" - AttributeError: 'list' object has no attribute 'replace' "fasttext" AttributeError:“列表”对象没有属性“替换”, - AttributeError: 'list' object has no attribute 'replace', “AttributeError:'list' object 没有属性'replace' - "AttributeError: 'list' object has no attribute 'replace' AttributeError:Selenium Webdriver中的python对象没有属性 - AttributeError: object has no attribute in python in selenium webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM