python lxml xml.etree.ElementTree.Element 到字符串不会转换
python lxml xml.etree.ElementTree.Element to string will not convert
type(ikePanProfiles)
<class 'xml.etree.ElementTree.Element'>
etree.tostring(ikePanProfiles)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "src/lxml/etree.pyx", line 3367, in lxml.etree.tostring
(src/lxml/etree.c:82622)
TypeError: Type 'Element' cannot be serialized.
我正在访问一个 API,它以 "xml.etree.ElementTree.Element" 的对象类型响应,所以我不确定如何隐藏这个 tostring?
您的元素是 xml
库中的一个对象,您正在尝试使用 lxml
对其进行字符串化。要么更改您的代码,使您的元素成为 lxml
库中的对象,要么使用 xml.etree.ElementTree.tostring
对其进行字符串化。
type(ikePanProfiles)
<class 'xml.etree.ElementTree.Element'>
etree.tostring(ikePanProfiles)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "src/lxml/etree.pyx", line 3367, in lxml.etree.tostring
(src/lxml/etree.c:82622)
TypeError: Type 'Element' cannot be serialized.
我正在访问一个 API,它以 "xml.etree.ElementTree.Element" 的对象类型响应,所以我不确定如何隐藏这个 tostring?
您的元素是 xml
库中的一个对象,您正在尝试使用 lxml
对其进行字符串化。要么更改您的代码,使您的元素成为 lxml
库中的对象,要么使用 xml.etree.ElementTree.tostring
对其进行字符串化。