dictionary question
Karl Pflästerer
sigurd at 12move.de
Wed Feb 4 18:01:50 EST 2004
On 4 Feb 2004, José Carlos <- josecarlos at siadv.com wrote:
> i have a dictionary. inside this dictionary i have several list and inside
> each list i have data.
> How can i do for add data to these list.
> conex = {'tipoconex': ['1', '0'], 'conexionS': ['cliente1', 'cliente2'],
> 'clave': ['pepo', 'joan'], 'usuario': ['pepe', 'juan']}
If you write conex[Key] the object returned is the corresponding value;
if the value is a list you can use all list methods with that object.
E.g:
>>> conex = {'tipoconex': ['1', '0'], 'conexionS': ['cliente1', 'cliente2'],
... 'clave': ['pepo', 'joan'], 'usuario': ['pepe', 'juan']}
>>> conex['clave'].append('juan')
>>> conex
{'clave': ['pepo', 'joan', 'juan'], 'conexionS': ['cliente1',
'cliente2'], 'tipoconex': ['1', '0'], 'usuario': ['pepe', 'juan']}
>>>
KP
--
'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe. "Lewis Carroll" "Jabberwocky"
More information about the Python-list
mailing list