Commit 257a3409 by BellCodeEditor

auto save

parent b7498cbe
Showing with 8 additions and 15 deletions
...@@ -3,17 +3,10 @@ student2 = {'语文': 97, '数学': 98, '英语': 90} ...@@ -3,17 +3,10 @@ student2 = {'语文': 97, '数学': 98, '英语': 90}
student3 = {'语文': 95, '数学': 100, '英语': 93} student3 = {'语文': 95, '数学': 100, '英语': 93}
score = {'悟空': student1, '诺依': student2, '小贝': student3} score = {'悟空': student1, '诺依': student2, '小贝': student3}
# 问询处
name = input("名字:") # input()方法询问名字并赋值给变量name
info=score[name] # 字典名score[name]赋值给变量info
# 查询并打印出输入的名字对应的所有科目的成绩 # for循环对字典进行遍历,将保存的分数以键值对的形式打印出来
while True : for k,v in info.items():
name = input("名字:") print(k,v) # 打印出变量k,v
if name in score : # 查询并打印出输入的名字对应的所有科目成绩
a = score[name] \ No newline at end of file
print('*'*30)
for k,v in a.items():
print(k,v)
break
else:
print('输入错误')
\ No newline at end of file
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