在下面的例子中,我们没有获得相同的返回类型。
一个是Element
,另一个是xml.etree.ElementTree.Element
为什么会有这种差异?
import xml.etree.cElementTree as ET1
import xml.etree.ElementTree as ET2
import multiprocessing
tree1 = ET1.parse('country_data.xml')
root1 = tree1.getroot()
manager1 = multiprocessing.Manager()
elems_saved1 = manager1.dict()
tree2 = ET2.parse('country_data.xml')
root2 = tree2.getroot()
type(root1)
<type 'Element'>
type(root2)
<class 'xml.etree.ElementTree.Element'>
可能是因为这个差异,它失败了,如上所述的错误 Using ElementTree works but not with cElementTree , throws TypeError
请尝试帮助解决此问题......
提前致谢