Answers for "how to convert a str to a list of lists"

4

python string list to list

>>> import ast
>>> x = '[ "A","B","C" , " D"]'
>>> x = ast.literal_eval(x)
>>> x
['A', 'B', 'C', ' D']
>>> x = [n.strip() for n in x]
>>> x
['A', 'B', 'C', 'D']
Posted by: Guest on May-06-2021

Code answers related to "how to convert a str to a list of lists"

Python Answers by Framework

Browse Popular Code Answers by Language