xml 파일 쓰기, xml 파일 헤더 쓰기

CODEDRAGON Development/Python

반응형


 

 

xml 파일 쓰기

from xml.etree.ElementTree import ElementTree

write("output.xml", encoding="utf-8", xml_declaration=True)

 

parameter

description

output.xml

출력할 xml 파일명

encoding

파일의 인코딩방식 지정

xml_declaration

True

 

 

 

 

 

xml 파일 헤더 쓰기

xml파일 생성시 write()메소드의 encoding 매개변수가 'utf-8' 지정이 되어 있고 xml_declaration 인자가 True 지정되어야만 xml파일 생성시 xml 파일 헤더인 <?xml version='1.0' encoding='utf-8'?> 파일의 첫라인에 추가되어집니다.

코드

출력결과

write("output.xml")


 

write("output.xml", encoding="utf-8", xml_declaration=True)


 

 



반응형

'Development > Python' 카테고리의 다른 글

반복 ?  (0) 2020.03.05
노드 생성 및 노드 추가하기  (0) 2020.03.03
Selenium WebDriver  (0) 2020.03.02
Selenium WebDriver 메소드  (0) 2020.03.02
re 모듈(regular expression)  (0) 2020.03.01