Nim*_*ims 8 python xml encoding declaration
我使用python创建了一个XML文件.但XML声明只有版本信息.如何使用XML声明包含编码,如:
<?xml version="1.0" encoding="UTF-8"?>
Run Code Online (Sandbox Code Playgroud)
>>> from xml.dom.minidom import Document
>>> a=Document()
>>> a.toprettyxml(encoding="utf-8")
'<?xml version="1.0" encoding="utf-8"?>\n'
Run Code Online (Sandbox Code Playgroud)
要么
>>> a.toxml(encoding="utf-8")
'<?xml version="1.0" encoding="utf-8"?>'
Run Code Online (Sandbox Code Playgroud)
您可以document.writexml()以相同的方式设置函数的编码.