如何将类似json或xml的字符串转换为可用的python对象

2024-09-28 21:03:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个从另一个代码发送的数据结构,无法获取原始数据类型。你知道吗

Item 1: 
    Name 1
        attribute1 = something1
        attribute2 = something2
    otherAttribute1 = otherthing1
    otherAttribute2 = otherthing2

Item 2: 
    Name 1
        attribute1 = something1
        attribute2 = something2
    otherAttribute1 = otherthing1
    otherAttribute2 = otherthing2

数据以unicode字符串的形式输入,如上所述。乍一看像是json。我能找到的其他帖子处理的是一个json字符串,但包含分隔符。在这种情况下,只有间距。你知道吗

enter image description here


Tags: 字符串代码namejson数据结构原始数据itemsomething2