本文整理汇总了Python中elementtree.ElementTree.SubElement.attrib["type"]方法的典型用法代码示例。如果您正苦于以下问题:Python SubElement.attrib["type"]方法的具体用法?Python SubElement.attrib["type"]怎么用?Python SubElement.attrib["type"]使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elementtree.ElementTree.SubElement
的用法示例。
在下文中一共展示了SubElement.attrib["type"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TextElement
# 需要导入模块: from elementtree.ElementTree import SubElement [as 别名]
# 或者: from elementtree.ElementTree.SubElement import attrib["type"] [as 别名]
def TextElement(root, name, detail_value):
if detail_value:
te = SubElement(root, name)
if detail_value.type == "text/html": detail_value.type = "html"
if detail_value.type == "text/plain": detail_value.type = "text"
te.attrib["type"] = detail_value.type
te.text = detail_value.value
示例2: LinkElement
# 需要导入模块: from elementtree.ElementTree import SubElement [as 别名]
# 或者: from elementtree.ElementTree.SubElement import attrib["type"] [as 别名]
def LinkElement(root, name, link):
if link:
le = SubElement(root, name)
if (link.has_key("rel")): le.attrib["rel"] = link.rel
if (link.has_key("title")): le.attrib["title"] = link.title
if (link.has_key("type")):
le.attrib["type"] = link.type
if (link.has_key("href")): le.attrib["href"] = link.href