我有一个文件trace.xml
。该文件的第一行是<?xml version="1.0" encoding="UTF-8"?>
。我尝试使用以下命令读取数据:
with open('trace.xml') as fobj:
xml=fobj.read()
root = etree.fromstring(xml)
但是,这会产生以下错误:ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
我假设这是因为我上面提到的第一个标签。有没有办法解决这个问题?如果有任何帮助,我们将不胜感激
试着改变
到
看看它是否有效
相关问题 更多 >
编程相关推荐