Python:读取可更改的XML文件

时间:2018-01-12 12:31:53

标签: python xml elementtree

假设我有这段代码:

import xml.etree.ElementTree as ET
from time import sleep

def get_src():
    while True:
        path = "input.xml"
        root = ET.parse(path).getroot()
        nodes = root.findall('body/video')
        for node in nodes:
            src = node.get('src')

            yield src

for i in get_src():
    print(i)
    sleep(3)

当xml文件的内容发生变化且循环已经在运行时,如何让python刷新nodes

0 个答案:

没有答案