Python ElementTree,fromstring()错误-AttributeError:';元素';对象没有属性';getroot';

Python ElementTree,fromstring()错误-AttributeError:';元素';对象没有属性';getroot';,python,xml,Python,Xml,我使用了parse函数来修改一个xml,它工作正常,但我尝试使用.fromstring,它显示了一个错误 AttributeError:“元素”对象没有属性“getroot” 下面是代码的一部分 AttributeError: 'Element' object has no attribute 'getroot' 这是因为fromstring方法已经返回了根对象。因此,无论从“fromstring()”方法存储信息的var是什么,该var都是根。这是一条错误消息,而不是代码。元素对象没有get

我使用了parse函数来修改一个xml,它工作正常,但我尝试使用.fromstring,它显示了一个错误

AttributeError:“元素”对象没有属性“getroot”

下面是代码的一部分

AttributeError: 'Element' object has no attribute 'getroot'

这是因为fromstring方法已经返回了根对象。因此,无论从“fromstring()”方法存储信息的var是什么,该var都是根。

这是一条错误消息,而不是代码。
元素
对象没有
getroot()
方法,而
ElementTree
有。发布引发错误的代码。