我有以下python脚本将数据存储存储为xml文件:
f=open('/Users/tests/test1/FileList_2013a.dat','w')
tree = xml.etree.ElementTree.fromstring( result )
for g in tree.getiterator("Granule"):
print g.attrib['name']
if options.url != None:
for u in g.getiterator("Url"):
if u.attrib.has_key('extensions') and u.attrib["extensions"] != "":
print "%s.%s" % (u.attrib["url"], u.attrib["extensions"])
else:
print u.attrib["url"]
f.write(u.attrib["url"] + '\n')
如何每2次写入文件一次?
谢谢!
João