Python: can I have a list with named indices?

前端 未结 8 1571
天涯浪人
天涯浪人 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:46

    Python has lists and dicts as 2 separate data structures. PHP mixes both into one. You should use dicts in this case.

提交回复
热议问题