【问题标题】:I have to remove some text in data from xpath using strip or split function我必须使用 strip 或 split 函数从 xpath 中删除数据中的一些文本
【发布时间】:2019-07-18 04:53:22
【问题描述】:

实际位置

"(1)Basking Ridge, NJ"

预计位置

"Basking Ridge, NJ"

【问题讨论】:

  • 这似乎是一个 Python 问题,而不是 XPath 问题,所以它被错误地标记了。

标签: python xpath split strip


【解决方案1】:

你可以这样做:

>>> location = "(1)Basking Ridge, NJ"
>>> location[3:]
'Basking Ridge, NJ'

【讨论】:

  • location = clean(player.xpath('./td[2]//span/text()')) x = location[3:]TypeError: 'NoneType' 对象不可下标
猜你喜欢
  • 1970-01-01
  • 2023-02-02
  • 1970-01-01
  • 2011-09-07
  • 1970-01-01
  • 2016-02-04
  • 2013-01-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多