How to print a dictionary's key?

前端 未结 20 829
眼角桃花
眼角桃花 2020-11-27 09:22

I would like to print a specific Python dictionary key:

mydic = {}
mydic[\'key_name\'] = \'value_name\'

Now I can check if mydic.has_

20条回答
  •  爱一瞬间的悲伤
    2020-11-27 09:36

    Additionally you can use....

    print(dictionary.items()) #prints keys and values
    print(dictionary.keys()) #prints keys
    print(dictionary.values()) #prints values
    

提交回复
热议问题