1 遍历key的值
scores_dict = {'语文': 105, '数学': 140, '英语': 120}
for key in scores_dict:
print(key)
2 遍历value的值
scores_dict = {'语文': 105, '数学': 140, '英语': 120}
for value in scores_dict.values():
print(value)
3 遍历字典键值对
scores_dict = {'语文': 105, '数学': 140, '英语': 120}
for key in scores_dict:
print(key + ":" + str(scores_dict[key])) # 返回字符串
>>本文地址:http://www.whbdqn.com/html/10238.html
注:本站稿件未经许可不得转载,转载请保留出处及源文件地址。
上一篇:Python字典使用教程:Python字典的常用方法
下一篇:没有了
北大青鸟
IT小助手扫描上方二维码添加好友,请备注:177,享学习福利。