mar joe wrote: > salve a tutti qualcuno sa come aggiungere dizionari diversi ad un > dizionario sotto la stessa chiave > > >>> dict1={}
Metti gli spazi intorno all'uguale: >>> dict1 = {} > >>> dict2={} > >>> dict={} Non chiamare variabili col nome del tipo, poi non puoi più usare quest'ultimo. > >>> dict1['uno']=1 > >>> dict2['due']=2 > >>> dict['numeri']=dict1 > >>> dict['numeri']=dict2 > >>> dict > {'numeri': {'due': 2}} > > Come potete vedere è stato aggiunto soltanto l'ultimo dizionario il > primo invece no >>> d = {} >>> d['numeri'] = {'uno': 1, 'due': 2} >>> d {'numeri': {'due': 2, 'uno': 1}} o anche: >>> d['numeri'] = dict((('uno', 1), ('due', 2))) >>> d {'numeri': {'due': 2, 'uno': 1}} -- Nicola Larosa - http://www.tekNico.net/ The wealthiest individuals are neither the cleverest, the most creative, or the nicest people to spend time with. Career success does not guarantee happiness. We all know this. So why do people sacrifice their leisure, their health, their ability to be creative, and their relation- ships purely in order to earn more money? -- Carmine Coyote, June 2006 _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python