在python中将xml文件添加到队列

2024-09-29 17:09:55 发布

您现在位置:Python中文网/ 问答频道 /正文

如何将正在创建的xml文件添加到队列中?这个队列需要稍后由线程池执行

执行之后,队列中必须有8000个xml文件

from lxml import etree as ET
import subprocess
import os

def frange(start, end, step):
    tmp = start
    while(tmp <= end):
        yield tmp
        tmp += ste

os.chdir('C:\Users\Aravind_Sampathkumar\Desktop\IMLC')
fileCount = 1
tree = ET.parse('C:\Users\Aravind_Sampathkumar\Desktop\IMLC\BO\IMLC_v4p8_Aravind.xml')
root = tree.getroot()

for child in root.iter('Traces'):
    child.find('TS')
    child.find('TW')
    for i in frange(3,12.75,0.25):
        child.set('TS',str(i))
        for k in frange(3,12.75,0.25):
                child.set('TW',str(i))
                for child2 in root.iter('Stackup'):
                    child2.find('core_h')
                    for j in frange(2,4,0.5):
                        for child3 in root.iter('Definition'):
                            child3.set('modelname', 'Output{}.xml'.format(fileCount))
                            child2.set('core_h',str(j))
                            tree.write('C:\Users\Aravind_Sampathkumar\Desktop\IMLC\BO\Output{}.xml'.format(fileCount))
                            fileCount = fileCount+1

Tags: inimportchildfor队列rootxmlusers

热门问题