I get a dictionary like following,
{'members': '{"mgt.as.wso2.com": 4100,"as.wso2.com": 4300}', 'subdomain': 'mgt'}
In the key members value is passed within two single quotes. Is there a way to remove those single quotes. I want the dictionary like following,
{'members': {"mgt.as.wso2.com": 4100,"as.wso2.com": 4300}, 'subdomain': 'mgt'}
Evaluate the string value with literal_eval, and then assign it back to the key:
>>> import ast
>>> d['members'] = ast.literal_eval(d['members'])
>>> d['members']['as.wso2.com']
4300
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With