在带有“;”的文本之间划分标签

如何";"在行中的每个文本之间添加分隔符?实际上,我使用了';'join,但效果不佳,它包括在标记文本中"FRI 1",我想分为"FRI"和"1"。


# -*- coding:UTF-8 -*-

import sys

from selenium import webdriver

driver = webdriver.Firefox()

driver.get("url")

table = ['; '.join([j.text for j in i.find_elements_by_class_name('couponRow') if j.text]) for i in driver.find_elements_by_xpath('//*[@id="todds"]//div[@class="couponTable"]') if i.text]

for line in table:

    print line

driver.close()

预期结果:


Friday Matches; 

FRI ;1 ; Uruguay; vs; France; Expected In Play start selling time: ; 06/07 ; 22:00 ; 4.75 ; 2.92 ; 1.78

FRI ;2 ; Brazil; vs; Belgium; Expected In Play start selling time: ; 07/07 ; 02:00 ; 1.94 ; 3.05 ; 3.70

Saturday Matches ; 

SAT ;1 ; Sweden; vs; England; Expected In Play start selling time: ; 07/07 ; 22:00 ; 5.10 ; 2.95 ; 1.73

SAT ;2 ; Russia; vs; Croatia; Expected In Play start selling time: ; 08/07 ; 02:00 ; 3.85 ; 2.70 ; 2.07


慕的地8271018
浏览 139回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python