Suppose a string s="[1,2,3]"
I want the list to be l=[1,2,3]
, where type(l)
is list
How can I achieve this
Suppose a string s="[1,2,3]"
I want the list to be l=[1,2,3]
, where type(l)
is list
How can I achieve this
Try this ,
In [3]: l = eval(s)
In [4]: print l
[1, 2, 3]
import json
s="[1,2,3]"
s_list = json.loads(s)
print(type(s_list))
out:
<type 'list'>