import os import xml.etree.ElementTree as ET from xml.etree.ElementTree import Element import gflags import sys from PIL import Image Flags = gflags.FLAGS gflags.DEFINE_string( 'source_dir1', 'C:/Users/Administrator/Desktop/test/test1', 'source_dir1') gflags.DEFINE_string( 'source_dir2', 'C:/Users/Administrator/Desktop/test/test2', 'source_dir2') gflags.DEFINE_string( 'result_dir', 'C:/Users/Administrator/Desktop/test/result', 'result_dir') def copy_img(inputpath,outputpath): for rt ,folders,files in os.walk(inputpath): for folder in folders: folder_path = os.path.join(rt,folder) files = os.listdir(folder_path) for file in files: if file.endswith('jpg'): dir= outputpath + '/' + folder oldpath = os.path.join(folder_path,file) newpath = os.path.join(dir, file) img = Image.open(oldpath) img.save(newpath) print('save successfully %s'%newpath) def delect_node(inputpath,sku): for rt ,folder,files in os.walk(inputpath): for file in files: if file.endswith('xml'):
Python 读写xml,合并两个xml文件object节点,并完成缩进问题
最新推荐文章于 2022-11-05 23:49:30 发布
本文介绍了如何使用Python进行XML文件的读写操作,特别是合并两个XML文件中的object节点,并解决了合并后文件的缩进格式问题,确保了合并后的XML结构清晰易读。
摘要由CSDN通过智能技术生成