-1

I would like to know how to transform this string,

"[{'id': 453, 'name': 'Paulo'}]"

into a list, being the dictionary the first element of the list.

How can I do it?

Rann Lifshitz
  • 4,040
  • 4
  • 22
  • 42

1 Answers1

1

Do this:

>>> from ast import literal_eval
>>> 
>>> 
>>> literal_eval("[{'id': 453, 'name': 'Paulo'}]")
[{'id': 453, 'name': 'Paulo'}]
Ahsanul Haque
  • 10,676
  • 4
  • 41
  • 57