Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中使用lxml库解析xml时出错_Python_Xml_Lxml_Pretty Print - Fatal编程技术网

在Python中使用lxml库解析xml时出错

在Python中使用lxml库解析xml时出错,python,xml,lxml,pretty-print,Python,Xml,Lxml,Pretty Print,我无法使用pretty_print参数打印xml。你知道会出什么问题吗 我附上代码样本以及 谢谢 import xml.etree.cElementTree as etree import os def main(): root = etree.Element("root") Series = etree.SubElement(root, "Element") SeriesID = etree.SubElement(Series, "Index") Ser

我无法使用pretty_print参数打印xml。你知道会出什么问题吗

我附上代码样本以及

谢谢

import xml.etree.cElementTree as etree
import os

def main():

    root = etree.Element("root")

    Series = etree.SubElement(root, "Element")

    SeriesID = etree.SubElement(Series, "Index")
    SeriesID.text = "80379"


    #print str(etree)
    #print(etree.tostring(root, pretty_print=True))

    print(etree.tostring(root))

if __name__ == "__main__":
    main()
没有
pretty\u print
参数

另一方面,有一个
pretty\u print
参数