I try to extract the number from the dictionary value but I can't get it as the int I need.
print(contador['Attributes'])
#Respuesta
{'ApproximateNumberOfMessages': '30'}
print(contador['Attributes'].values())
#Respuesta
dict_values(['30'])
I try to extract the number from the dictionary value but I can't get it as the int I need.
print(contador['Attributes'])
#Respuesta
{'ApproximateNumberOfMessages': '30'}
print(contador['Attributes'].values())
#Respuesta
dict_values(['30'])
Having as key
ApproximateNumberOfMessages
, you can access it as follows:In this way, it prints
30
.What's going on? That he is not a
int
. If we use the methodtype
:You will see that it returns :
So you could change it like this :
If you print :
You will see that it returns :
This is an example with a dictionary whose key is
'Attributes'
and the value is another dictionary. If you want to get the list of all the values in the second dictionary, converted to integers, you can use themap
. In the case that you only want to get the integer value of one of the keys of the second dictionary, you can do it withint(contador['Attributes']['llave_del_segundo_diccionario'])