Home  >  Q&A  >  body text

python - 想请问下beautifulsoup中的NavigableString具体是什么东西

看文档没怎么弄明白,请各位给个比较直观的描述,顺别说一下这个东西有什么用啊

ringa_leeringa_lee2742 days ago1045

reply all(3)I'll reply

  • 黄舟

    黄舟2017-04-17 11:48:59

    NavigableString object, used to manipulate strings, such as "Page title" and "This is paragraph". http://www.crummy.com/software/BeautifulSoup/bs3/documentation.zh.html

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 11:48:59

    The official does not have a detailed description of this object, but during use it was discovered that it is actually an inherited subclass of Python's str object, and there is actually no difference.
    I wonder what problems the poster encountered with this?

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:48:59

    NavigableString is understood literally as a traversable string, and
    is one of the four types BeautifulSoup of tag|NavigableString|BeautifulSoap|Comment objects.

    soup.tag.string # 用来获取便签内部的文字内容,通过.string来调用
    # 可以通过type()方法查看类型
    print type(soup.tag.string)
    # <class 'bs4.element.NavigableString'>

    reply
    0
  • Cancelreply