I have a string:
s= \"[7, 9, 41, [32, 67]]\"
and I need to convert that string into a list:
l= [7, 9, 41, [32, 67]]
It is another answer, But I don't suggest you.Because exec is dangerous.
exec
>>> s= "[7, 9, 41, [32, 67]]" >>> try: ... exec 'l = ' + s ... l ... except Exception as e: ... e [7, 9, 41, [32, 67]]