import bs4
html = '''
<title>小丑之家</title>
<div class="info" float="left">Welcome to Joker's home</div>
<div class='info' float='right'>
<span>Good Good Study, Day Day Up</span>
<a href='https://www.bilibili.com></a>
<strong><!--无效--></strong>
</div>
'''
print("-------------获取内容-----------------")
print(soup.span.string)
print(soup.strong.string)
print(soup.strong.text) # 用text无法获取注释信息
This is running in a general Python environment. The problem with the code above is that when <a href='https://www.bilibili.com'></a> is missing a single quote, running the Python code prompts an error that says print(soup.strong.string) 'NoneType' object has no attribute 'string', but completing the single quote does not result in this error. There is something wrong with the error here, I hope it can be corrected.


This is running in a general Python environment. The problem with the code above is that when


<a href='https://www.bilibili.com'></a>is missing a single quote, running the Python code prompts an error that saysprint(soup.strong.string) 'NoneType' object has no attribute 'string', but completing the single quote does not result in this error. There is something wrong with the error here, I hope it can be corrected.