Python: can I have a list with named indices?

前端 未结 8 1585
天涯浪人
天涯浪人 2020-12-10 10:06

In PHP I can name my array indices so that I may have something like:

$shows = Array(0 => Array(\'id\' => 1, \'name\' => \'Sesame Street\'), 
               


        
8条回答
  •  庸人自扰
    2020-12-10 10:50

    I think what you are asking is about python dictionaries.There you can named your indices as you wish . For ex:

    dictionary = {"name": "python", "age": 12}
    

提交回复
热议问题