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

前端 未结 6 2374
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:40

    This may meet your need better:

    Dictionary = {"Forename":"Paul","Surname":"Dinh"}
    KeyList = ["Forename", "Surname"]
    for Key in KeyList:
        print Key,"=",Dictionary[Key]
    

提交回复
热议问题