本文整理匯總了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