2. 使用lxml模块,它是一个高性能的XML和HTML解析器,可以有效的降低内存占用。
3. 使用iterparse()函数,它可以遍历XML文档,可以降低内存占用。
4. 使用xml.sax模块,它是一个基于事件驱动的XML解析器,可以有效的降低内存占用。
(1)解析xml报错 ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
得到上述的xml的类, 需要转化为string,要加参数 encoding='unicode'