Gre*_*mer 3 python dictionary ordereddictionary python-3.x ordereddict
我有这个清单
a = [OrderedDict([('a','b'), ('c','d'), ('e', OrderedDict([('a','b'), ('c','d') ]))])]
Run Code Online (Sandbox Code Playgroud)
我想在字典中转换 OrderedDict 。
你知道我该怎么办吗?
谢谢 !
要转换嵌套OrderedDict
,您可以使用包json
>>> import json
>>> json.loads(json.dumps(a))
[{'a': 'b', 'c': 'd', 'e': {'a': 'b', 'c': 'd'}}]
Run Code Online (Sandbox Code Playgroud)