How to convert an OrderedDict into a regular dict in python3

后端 未结 8 608
天命终不由人
天命终不由人 2020-12-04 09:43

I am struggling with the following problem: I want to convert an OrderedDict like this:

OrderedDict([(\'method\', \'constant\'), (\'data\', \'1.         


        
8条回答
  •  死守一世寂寞
    2020-12-04 10:17

    Its simple way

    >>import json 
    >>from collection import OrderedDict
    
    >>json.dumps(dict(OrderedDict([('method', 'constant'), ('data', '1.225')])))
    

提交回复
热议问题