python - Convert a tuple into a dictionary -


i've looked on internet , consulted few books can't seem find example illustrates trying do. loathe ask on because feels basic question i've been banging head against wall last few hours here goes:

how turn this:

   item = ((100,may),(160,june),(300,july),(140,august))   

into this:

                {                 item:[                     {                         value:100,                         label:'may'                     },                     {                         value:160,                         label:'june'                     },                     {                         value:300,                         label:'july'                     },                     {                         value:140,                         label:'august'                     }                 ]                 } 

{'item': [dict(value=value, label=label) value, label in item]} 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -