本文整理汇总了Python中bs4.dammit.EntitySubstitution.substitute_xml方法的典型用法代码示例。如果您正苦于以下问题:Python EntitySubstitution.substitute_xml方法的具体用法?Python EntitySubstitution.substitute_xml怎么用?Python EntitySubstitution.substitute_xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bs4.dammit.EntitySubstitution
的用法示例。
在下文中一共展示了EntitySubstitution.substitute_xml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: substitute_xml
# 需要导入模块: from bs4.dammit import EntitySubstitution [as 别名]
# 或者: from bs4.dammit.EntitySubstitution import substitute_xml [as 别名]
def substitute_xml(cls, ns):
return cls._substitute_if_appropriate(
ns, EntitySubstitution.substitute_xml)
示例2: _formatter_for_name
# 需要导入模块: from bs4.dammit import EntitySubstitution [as 别名]
# 或者: from bs4.dammit.EntitySubstitution import substitute_xml [as 别名]
def _formatter_for_name(self, name):
"Look up a formatter function based on its name and the tree."
if self._is_xml:
return self.XML_FORMATTERS.get(
name, EntitySubstitution.substitute_xml)
else:
return self.HTML_FORMATTERS.get(
name, HTMLAwareEntitySubstitution.substitute_xml)
示例3: format_string
# 需要导入模块: from bs4.dammit import EntitySubstitution [as 别名]
# 或者: from bs4.dammit.EntitySubstitution import substitute_xml [as 别名]
def format_string(self, s, formatter='minimal'):
"""Format the given string using the given formatter."""
if not callable(formatter):
formatter = self.FORMATTERS.get(
formatter, EntitySubstitution.substitute_xml)
if formatter is None:
output = s
else:
output = formatter(s)
return output