How can I convert this string to list of lists? [duplicate]

>>> import ast
>>> ast.literal_eval('[[0,0,0], [0,0,1], [1,1,0]]')
[[0, 0, 0], [0, 0, 1], [1, 1, 0]]

For tuples

>>> ast.literal_eval('[(0,0,0), (0,0,1), (1,1,0)]')
[(0, 0, 0), (0, 0, 1), (1, 1, 0)]

Leave a Comment