type(soup.h1.text)
>>>class 'str'
type(soup.h1.string)
>>>class 'bs4.element.NavigableString'
class CustomStr:
def __init__(self, str_):
self.__str = str_
def d_space(self):
return "".join(self.__str.split())
soup = BeautifulSoup(html,"html.parser")
var = soup.title.string
print(var)
print(type(var))
В var будет как раз NavigableString:Hello World! Site Title
<class 'bs4.element.NavigableString'>