A
A
Anton2021-09-02 18:31:15
Python
Anton, 2021-09-02 18:31:15

How to parse values ​​into python from such a server response?

Hello, help me parse the name value from such a server response, I just can’t figure it out. Tried json, nothing comes out.
The example of the server response itself:
[{'name': 'Vasya', 'age': '25'}]
And output in print the result the name that will be in the response of the server
Vasya

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Renat Ataev, 2021-09-02
@boypush

Your dictionary is in the list. Get a dictionary from the list and then refer

obj = [{'name': 'Vasya', 'age': '25'}]
obj_dict = obj[0]
print(obj_dict['name'])

Learn, don't ask stupid questions!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question