如标题所示,etree.froms(xml)出现如下错误:
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
还以为是xml文件的格式错误,结果改了还是报错,
看到了这篇文章:https://blog.csdn.net/suiyuan2009/article/details/104097491
在 xml后面加上 **.encode(‘utf-8’) ** 就解决问题了
xml = etree.fromstring(xml_str.encode('utf-8'))