当前位置: 代码迷 >> 综合 >> python xml中写入文件如果要带xml头该怎么办
  详细解决方案

python xml中写入文件如果要带xml头该怎么办

热度:61   发布时间:2024-02-09 12:17:14.0

python xml中写入文件如果要带

<?xml version="1.0" encoding="utf-8"?> 

字样应该怎么办? 

doc = minidom.Document()  
f = open(filename, "w")
doc.writexml(f, indent="  ", addindent='\t', newl="\n",encoding="utf-8")
f.close()

 

  相关解决方案