How to implement associative array (not dictionary) in Python?

前端 未结 6 2403
Happy的楠姐
Happy的楠姐 2020-12-17 21:57

I trying to print out a dictionary in Python:

Dictionary = {\"Forename\":\"Paul\",\"Surname\":\"Dinh\"}
for Key,Value in Dictionary.iteritems():
  print Key,         


        
6条回答
  •  死守一世寂寞
    2020-12-17 22:25

    'but dictionaries in Python are sorted by values' maybe I'm mistaken here but what game you that ideea? Dictionaries are not sorted by anything.

    You would have two solutions, either keep a list of keys additional to the dictionary, or use a different data structure like an array or arrays.

提交回复
热议问题