python #xml
-
[Python]Python으로 .xml 파일 내용 수정하기기타 정보 2020. 4. 30. 20:04
폴더 안에 있는 모든 xml파일 내용을 일괄적으로 수정할 필요가 생겨 코드를 작성하게 되었다 1. 필요한 라이브러리 import import os import xml.etree.ElementTree as ET xml.etree.ElementTree는 xml 파싱을 위한 라이브러리 중 하나이다. os는 폴더나 파일에 접근하기 위해 필요하다. 2. 폴더안에 있는 모든 xml 파일 이름 가져오기 targetDir = r"C:\Users\lab_research\data\images\train" ##targetDir에서 .xml파일 이름들 리스트로 가져오기 file_list = os.listdir(targetDir) xml_list = [] for file in file_list: if '.xml' in file..