Commit 5f1c134a by BellCodeEditor

auto save

parent 6791be70
Showing with 18 additions and 13 deletions
...@@ -7,13 +7,18 @@ score = {'悟空': student1, '诺依': student2, '小贝': student3} ...@@ -7,13 +7,18 @@ score = {'悟空': student1, '诺依': student2, '小贝': student3}
# 查询并打印出输入的名字对应的所有科目的成绩 # 查询并打印出输入的名字对应的所有科目的成绩
while True : while True :#无限循环
name = input("名字:") print("退出请按q")#提示内容
if name in score : name = input("名字:")#获取名字
a = score[name] print('*'*30)#作为分割线
print('*'*30) if name in score :#条件判断
for k,v in a.items(): info = score[name]#符合条件执行内容
for k,v in info.items():#获取字典中的键值对
print(k,v) print(k,v)
break print('*'*30)
elif name == "q":
break#跳出循环
else: else:
print('输入错误') print('输入错误')
\ No newline at end of file print("*"*30)
print("程序结束")
\ No newline at end of file
...@@ -10,6 +10,6 @@ score = {'悟空': student1, '诺依': student2, '小贝': student3} ...@@ -10,6 +10,6 @@ score = {'悟空': student1, '诺依': student2, '小贝': student3}
naem = input("名字")#获取名字 naem = input("名字")#获取名字
if name in score:#条件判断,这个名字在不在字典中!!! if name in score:#条件判断,这个名字在不在字典中!!!
info = score[naem] info = score[naem]
input(info)# input(info)
else:# else:
input("您输入的有误,请重新输入!!!")# input("您输入的有误,请重新输入!!!")
\ No newline at end of file \ 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