本文整理汇总了Python中elementtree.ElementTree.SubElement.attrib['start']方法的典型用法代码示例。如果您正苦于以下问题:Python SubElement.attrib['start']方法的具体用法?Python SubElement.attrib['start']怎么用?Python SubElement.attrib['start']使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elementtree.ElementTree.SubElement
的用法示例。
在下文中一共展示了SubElement.attrib['start']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: toelem
# 需要导入模块: from elementtree.ElementTree import SubElement [as 别名]
# 或者: from elementtree.ElementTree.SubElement import attrib['start'] [as 别名]
def toelem(pattern, elem):
from elementtree.ElementTree import SubElement
patt = SubElement(elem, 'pattern')
patt.attrib['name'] = str(pattern.name)
patt.attrib['beats'] = str(pattern.beats)
for note in pattern:
sub = SubElement(patt, 'note')
sub.attrib['start'] = str(note.start)
sub.attrib['stop'] = str(note.stop)
sub.attrib['pitch'] = str(note.pitch)
示例2: write
# 需要导入模块: from elementtree.ElementTree import SubElement [as 别名]
# 或者: from elementtree.ElementTree.SubElement import attrib['start'] [as 别名]
def write(pattern, fpath):
from elementtree.ElementTree import Element, SubElement, ElementTree
from elementtree import TidyTools
root = Element('xml')
patt = SubElement(root, 'pattern')
patt.attrib['name'] = str(pattern.name)
patt.attrib['beats'] = str(pattern.beats)
for note in pattern:
sub = SubElement(patt, 'note')
sub.attrib['start'] = str(note.start)
sub.attrib['stop'] = str(note.stop)
sub.attrib['pitch'] = str(note.pitch)
ElementTree(root).write(fpath)
os.system('tidy -xml -iqm \"%s\"' % fpath)