我发现了一个较旧的Python代码,其中包含以下内容:
return BeautifulSoup(m.group(1),
convertEntities=BeautifulSoup.HTML_ENTITIES).contents[0].string
当我尝试运行代码时,我收到此错误:
AttributeError: type object 'BeautifulSoup' has no attribute 'HTML_ENTITIES
有人可以解释一下这行的含义:
BeautifulSoup(m.group(1),convertEntities=BeautifulSoup.HTML_ENTITIES).contents[0].string
如何在使用formater的新版本中完成此操作?
我知道这里有一个类似的问题: BeautifulSoup' has no attribute 'HTML_ENTITIES 但由于我不熟悉BeautifulSoup,我无法将线路转换为新格式。
非常感谢您对此的任何帮助。
答案 0 :(得分:1)
您根本不需要在此处指定convertEntities
,该行为(将HTML实体转换为其Unicode代码点)现在是默认。