writexml方法:

  • Post author:
  • Post category:其他


writexml(writer, indent, addindent, newl, encoding)

参数:

1、writer是文件对象

2、indent是每个tag前填充的字符,如:’ ‘,则表示每个tag前有两个空格。根节点是否缩进

3、addindent是每个子结点的缩近字符,如下面的例子中单引号中我直接用的tab键。字节点是否缩进

4、newl是每个tag后填充的字符,如:’\n’,则表示每个tag后面有一个回车

5、encoding是生成的XML信息头中的encoding属性值,在输出时minidom并不真正进行编码的处理,如果你保存的文本内容中有汉字,则需要自已进行编码转换。

转载于:https://www.cnblogs.com/hymmiaomiao/p/8991382.html