Py学习  »  Python

如何在python中从web元素中移除coma?

Sumaria Iqbal • 6 年前 • 2254 次点击  

如何删除 , 来自WebElement?

细节:

我用selenium抓取了一个网页,但我想从中删除 ,

例如:

如果我放弃 hey, welcome 2020 在这将进入我的csv文件之前,我想删除 ,

这是我的代码:

if (driver.find_elements_by_css_selector('.restaurants-detail-overview-cards-LocationOverviewCard__addressLink--1pLK4 ._2wKz--mA .restaurants-detail-overview-cards-LocationOverviewCard__detailLinkText--co3ei')):
    address = driver.find_elements_by_css_selector('.restaurants-detail-overview-cards-LocationOverviewCard__addressLink--1pLK4 ._2wKz--mA .restaurants-detail-overview-cards-LocationOverviewCard__detailLinkText--co3ei')

else:
    address = 'NONE'

with open(save,'a',encoding='utf-8') as s:
    for i in range(1):
        addresst = address

        if addresst == 'NONE':
            addresst = str(address)
        else:
            addresst = address[i].text

        s.write(addresst + '\n')
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/51379
文章 [ 2 ]  |  最新文章 6 年前