python中遍历字典有如下两种方式
>>> d = {"a": 1, "b":2, "c":3}
>>> for k in d:
... print(k, d[k])
...
a 1
b 2
c 3
>>>
>>> for k, v in d.items():
... print(k, v)
...
a 1
b 2
c 3
关注公众号「Python之禅」,回复「1024」免费获取Python资源
python中遍历字典有如下两种方式
>>> d = {"a": 1, "b":2, "c":3}
>>> for k in d:
... print(k, d[k])
...
a 1
b 2
c 3
>>>
>>> for k, v in d.items():
... print(k, v)
...
a 1
b 2
c 3
关注公众号「Python之禅」,回复「1024」免费获取Python资源