我正在尝试从 XML 文档中提取转义节点。节点的原始文本如下所示:
<Notes>{"Phase": 0, "Flipper": 0, "Guide": 0,
"Sample": 0, "Triangle8": 0, "Triangle5": 0,
"Triangle4": 0, "Triangle7": 0, "Triangle6": 0,
"Triangle1": 0, "Triangle3": 0, "Triangle2": 0}</Notes>
我将文本拉出如下:
infile = ET.parse("C:/userfiles/EXP011/SESAME_60/SESAME_60_runinfo.xml")
r = infile.getroot()
XMLNS = "{http://example.com/foo/bar/runinfo_v4_3}"
x=r.find(".//"+XMLNS+"Notes")
print(x.text)
我希望得到:
{"Phase": 0, "Flipper": 0, "Guide"": 0,
"Sample": 0, "Triangle8": 0, "Triangle5": 0,
"Triangle4": 0, "Triangle7": 0, "Triangle6": 0,
"Triangle1": 0, "Triangle3": 0, "Triangle2": 0}
但是,相反,我得到了:
{"Phase": 0, "Flipper": 0, "Guide": 0,
"Sample": 0, "Triangle8": 0, "Triangle5": 0,
"Triangle4": 0, "Triangle7": 0, "Triangle6": 0,
"Triangle1": 0, "Triangle3": 0, "Triangle2": 0}
如何获取未转义的字符串?