python - 想请问下beautifulsoup中的NavigableString具体是什么东西
ringa_lee
ringa_lee 2017-04-17 11:46:59
0
3
1099

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

ringa_lee
ringa_lee

ringa_lee

reply all(3)
黄舟

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

Peter_Zhu

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?

洪涛

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'>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template