I have a method in Python 2.7 that returns a list as such:
[{u'usuario': u''}]
And I need to get just the value and store it in a unicode variable. In this case it would be an empty string, but it could be[{u'usuario': u'Pepe'}]
How would this be done in a simple way?
Python is a dynamically typed language, so for a variable to be of a certain type, it is enough to store a value of this type there, so the following lines
In a the list would be saved, but in b a unicode value is saved, which can be seen when printing b
Actually I need more context to be able to answer your question, but I'm going to assume some things and you tell me if it's what you're looking for.
I suppose you have a list of people, where each person with their characteristics is represented by a dictionary.
In this example I suppose that I have 3 people in my list: Javier, Elena and Maria. Each with their name and age.
If what I want is to only show the names of my users, I would do something like this: