I have message which is a list and JSON in it. I managed to get JSON with raw decode. The problem is
string = "["a,b","b,c"]"
How can I convert that string into a list?
I have message which is a list and JSON in it. I managed to get JSON with raw decode. The problem is
string = "["a,b","b,c"]"
How can I convert that string into a list?
Use ast.literal_eval
:
import ast
print(ast.literal_eval(string))
Since this is JSON, use the json
module:
import json
print(json.loads(string))
string = "['a,b','b,c']"
print(eval(string))