首页  >  问答  >  正文

python - 正则表达式匹配“\xa0”的问题

伊谢尔伦伊谢尔伦2717 天前387

全部回复(2)我来回复

  • 巴扎黑

    巴扎黑2017-04-18 10:12:04

    用strip()去掉首尾空格

    from scrapy.selector import Selector
    
    content = "<p>数量:100-200个&nbsp;&nbsp;&nbsp;&nbsp;</p>"
    strings = Selector(text=content).xpath('//p/text()').re_first(u'数量:(.+)\s$').strip()
    print(strings)
    print(len(strings))
    """
    100-200个
    8
    """
    

    回复
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:12:04

    '数量:(S+)'

    回复
    0
  • 取消回复