Answer the question
In order to leave comments, you need to log in
How to parse lists in a string?
Good afternoon. I need to parse a string containing lists into lists. Here is an example line content:
[
[1, "Иван Иванович Иванов", "Иванов И.И."],
[2, "Макар Макарович Макаров", "Макароы М.М."]
]
Answer the question
In order to leave comments, you need to log in
If I understand correctly, here is a more humane way:
import ast
data = '''[
[1, "Иван Иванович Иванов", "Иванов И.И."],
[2, "Макар Макарович Макаров", "Макароы М.М."]
]'''
res = ast.literal_eval(data)
#
type(res)
# <class 'list'>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question