import xml.etree.ElementTree as ET
import os
def change_xml(xml_path):
filelist = os.listdir(xml_path)
for xmlfile in filelist:
doc = ET.parse(xml_path+xmlfile)
root = doc.getroot()
sub1 = root.find('filename')
name = sub1.text
name = list(name)
name[-8] = '1'
sub1.text = "".join(name)
sub2 = root.find('path')
path = sub2.text
path = list(path)
path[-8] = '1'
sub2.text = "".join(path)
doc.write(xml_path+xmlfile)
new = sub1.text.rsplit('.',1)[0]
os.rename(xml_path+xmlfile , xml_path+new+'.xml')
xml_path = 'D:\\home\\2\\beifen\\'
change_xml(xml_path)