dict1 = {"a": "A", "b": "B"}
# 遍历字典所有key值
for k in dict1.keys():
print(k)
# 遍历字典所有key值另一种写法
for k in dict1:
print(k)
# 遍历字典中所有values值
for v in dict1.values():
print(v)
# 遍历字典中所有values值另一种写法
for k in dict1:
print(dict1[k])
原文:https://www.cnblogs.com/MasonHu/p/14364099.html