Commit 3a7783d9 by BellCodeEditor

auto save

parent 084e30ab
Showing with 4 additions and 3 deletions
...@@ -4,8 +4,9 @@ student3 = {'语文': 95, '数学': 100, '英语': 93} ...@@ -4,8 +4,9 @@ student3 = {'语文': 95, '数学': 100, '英语': 93}
score = {'悟空': student1, '诺依': student2, '小贝': student3} score = {'悟空': student1, '诺依': student2, '小贝': student3}
name = input("名字:") name = input("名字:") #input()方法询问名字并赋值给变量name
info=score[name] info=score[name] # 字典名[name]赋值给变量info
# for循环对字典进行遍历,将保存的分数以键值对的形式打印出来
for k,v in info.items(): for k,v in info.items():
print(k,v) print(k,v) # 打印出变量k,v
# 查询并打印出输入的名字对应的所有科目的成绩 # 查询并打印出输入的名字对应的所有科目的成绩
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment