How can I convert a str representation of the list
, such as the below string into a dictionary
?
a = '[100:0.345,123:0.34,145:0.86]'
Expected output :
{100:0.345,123:0.34,145:0.86}
First tried to convert the string into a list using ast.literal_eval
. But it's showing an error as : invalid syntax