How to iterate through a nested dict?

前端 未结 7 1041
谎友^
谎友^ 2020-12-08 23:50

I have a nested python dictionary data structure. I want to read its keys and values without using collection module. The data structu

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 00:09

    To get keys and values you need dict.items():

    for key, value in d.items():
        print(key)
    

    If you want just the keys:

    for key in d:
        print(key)
    

提交回复
热议问题