当前位置: 首页>>代码示例>>Python>>正文


Python Element.attrib["value"]方法代码示例

本文整理汇总了Python中xml.etree.cElementTree.Element.attrib["value"]方法的典型用法代码示例。如果您正苦于以下问题:Python Element.attrib["value"]方法的具体用法?Python Element.attrib["value"]怎么用?Python Element.attrib["value"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xml.etree.cElementTree.Element的用法示例。


在下文中一共展示了Element.attrib["value"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_attributes

# 需要导入模块: from xml.etree.cElementTree import Element [as 别名]
# 或者: from xml.etree.cElementTree.Element import attrib["value"] [as 别名]
 def add_attributes(self, node_or_edge, xml_obj, data, default):
     # Add attrvalues to node or edge
     attvalues = Element("attvalues")
     if len(data) == 0:
         return data
     if "start" in data or "end" in data:
         mode = "dynamic"
     else:
         mode = "static"
     for k, v in list(data.items()):
         # rename generic multigraph key to avoid any name conflict
         if k == "key":
             k = "networkx_key"
         attr_id = self.get_attr_id(make_str(k), self.xml_type[type(v)], node_or_edge, default, mode)
         if type(v) == list:
             # dynamic data
             for val, start, end in v:
                 e = Element("attvalue")
                 e.attrib["for"] = attr_id
                 e.attrib["value"] = make_str(val)
                 e.attrib["start"] = make_str(start)
                 e.attrib["end"] = make_str(end)
                 attvalues.append(e)
         else:
             # static data
             e = Element("attvalue")
             e.attrib["for"] = attr_id
             e.attrib["value"] = make_str(v)
             attvalues.append(e)
     xml_obj.append(attvalues)
     return data
开发者ID:rainest,项目名称:dance-partner-matching,代码行数:33,代码来源:gexf.py

示例2: add_attributes

# 需要导入模块: from xml.etree.cElementTree import Element [as 别名]
# 或者: from xml.etree.cElementTree.Element import attrib["value"] [as 别名]
 def add_attributes(self, node_or_edge, xml_obj, data, default):
     # Add attrvalues to node or edge
     attvalues = Element("attvalues")
     if len(data) == 0:
         return data
     mode = "static"
     for k, v in data.items():
         # rename generic multigraph key to avoid any name conflict
         if k == "key":
             k = "networkx_key"
         val_type = type(v)
         if type(v) == list:
             # dynamic data
             for val, start, end in v:
                 val_type = type(val)
                 if start is not None or end is not None:
                     mode = "dynamic"
                     self.alter_graph_mode_timeformat(start)
                     self.alter_graph_mode_timeformat(end)
                     break
             attr_id = self.get_attr_id(make_str(k), self.xml_type[val_type], node_or_edge, default, mode)
             for val, start, end in v:
                 e = Element("attvalue")
                 e.attrib["for"] = attr_id
                 e.attrib["value"] = make_str(val)
                 if start is not None:
                     e.attrib["start"] = make_str(start)
                 if end is not None:
                     e.attrib["end"] = make_str(end)
                 attvalues.append(e)
         else:
             # static data
             mode = "static"
             attr_id = self.get_attr_id(make_str(k), self.xml_type[val_type], node_or_edge, default, mode)
             e = Element("attvalue")
             e.attrib["for"] = attr_id
             if type(v) == bool:
                 e.attrib["value"] = make_str(v).lower()
             else:
                 e.attrib["value"] = make_str(v)
             attvalues.append(e)
     xml_obj.append(attvalues)
     return data
开发者ID:hagberg,项目名称:networkx,代码行数:45,代码来源:gexf.py


注:本文中的xml.etree.cElementTree.Element.attrib["value"]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。