首页 > 编程语言 > 详细

[python]deteval中groundtruth.xml内容重新排序

时间:2014-05-07 11:01:37      阅读:668      评论:0      收藏:0      [点我收藏+]

#xml api:http://www.cnblogs.com/lhj588/archive/2011/11/09/2242483.html

#dictionary operations: key in dict....

from xml.dom import minidom, Node
doc = minidom.parse(‘out.xml‘)
tagset=doc.firstChild
image=tagset.firstChild
images={}
while image:
# print image.toxml()
# props=dir(image)
# print type(image)
# print type(image)
if hasattr(image,"tagName"):
# print image.tagName+":"
# print str(eval("image.%s"%"tagName"))
for imagetag in image.childNodes:

imagename=image.getElementsByTagName("imagename")[0].childNodes[0].nodeValue
images[imagename]=image

# if hasattr(imagetag,"tagName"):
# if imagetag.tagName=="imagename":
# print imagetag.toxml()

image=image.nextSibling

# for i in images.keys():
# print i

print "<tagset>"
for i in range(1,419):
imagename=str(i)+".jpg"
if images.has_key(imagename):
print imagename+"formatted"
print images[imagename].toxml()
print "</tagset>"

[python]deteval中groundtruth.xml内容重新排序,布布扣,bubuko.com

[python]deteval中groundtruth.xml内容重新排序

原文:http://www.cnblogs.com/bigboy/p/3712947.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!