-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
  • 3,992
  • 4
  • 21
  • 41

1 Answers1

1

Do this:

>>> from ast import literal_eval
>>> 
>>> 
>>> literal_eval("[{'id': 453, 'name': 'Paulo'}]")
[{'id': 453, 'name': 'Paulo'}]
Ahsanul Haque
  • 9,865
  • 4
  • 35
  • 51