我有一个看起来像这样的XML字符串:
<Being>
<Animal name="mammal">
<Animal name="color">black</Animal>
<Animal name="spots">yes</Animal>
<Animal name="legs">4</Animal>
<Animal name="age">10</Animal>
</Animal>
<Animal name="mammal">
<Animal name="color">green</Animal>
<Animal name="spots">no</Animal>
<Animal name="legs">4</Animal>
<Animal name="age">5</Animal>
</Animal>
</being>
我想将其转换为Python字典,如下所示:
{Being: [{"mammal":{"color":"black", "spots":"yes", "legs": "4", "age":"10"}}, {"Reptile":{"color":"green", "spots":"no", "legs": "4", "age":"5"}}]}