【发布时间】:2019-07-24 04:36:22
【问题描述】:
raw_location = {Raynham, MA Topsham, ME
"Savannah, GA Cary, NC"
"'Bloomfield Hills,MI Arlington Heights,IL'
"}
我需要/在城市、州/城市、州之间
raw_location = clean(player.xpath('./td[2]//span/text()'))
cleaned_location = re.sub(r"\(\d+\)","", raw_location)
x = [{", ".join(["/".join(w.strip().split(" ")) for w in word.split(",")])} for word in [s for s in cleaned_location]]
实际输出:
{Raynham, MA Topsham, ME
"Savannah, GA Cary, NC"
"'Bloomfield Hills,MI Arlington Heights,IL'
L"}
预期输出:
{Raynham, MA/Topsham, ME
"Savannah, GA/Cary, NC"
"'Bloomfield Hills,MI/Arlington Heights,IL'
"}
【问题讨论】:
-
你尝试过什么?
-
raw_location = clean(player.xpath('./td[2]//span/text()')) clean_location = re.sub(r"(\d+)","/" , raw_location)
-
你能帮忙解决一下吗