Looping seems to not follow sequence

后端 未结 3 1927
耶瑟儿~
耶瑟儿~ 2020-12-20 20:24

I feel like I\'m missing something obvious here!

seq = {\'a\': [\'1\'], \'aa\': [\'2\'], \'aaa\': [\'3\'], \'aaaa\': [\'4\'], \'aaaaa\': [\'5\']}
for s in seq         


        
3条回答
  •  别那么骄傲
    2020-12-20 21:05

    Dictionaries are not ordered. If you need to rely on the ordering, you need an OrderedDict - there's one in the collections module in Python 2.7, or you can use one of the many recipes around.

提交回复
热议问题