[Solved] how to convert string consisted of list to real list [closed]


You can use ast.literal_eval to safely evaluate strings containing Python literals.

from ast import literal_eval

a="["Hello", "World!", 2]"
b = literal_eval(a)
# ["Hello", "World!", 2]

Note that the string can only be compromised of: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, and None (taken from the documentation here)

solved how to convert string consisted of list to real list [closed]