From a2f6efaeeade710f38c29404c93fbec597b42c60 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 24 Nov 2024 11:11:05 +0800 Subject: [PATCH] auto save --- 2-9-diy5.py | 20 ++++++++++++++++++++ diy2.py | 5 ----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 2-9-diy5.py delete mode 100644 diy2.py diff --git a/2-9-diy5.py b/2-9-diy5.py new file mode 100644 index 0000000..466ed52 --- /dev/null +++ b/2-9-diy5.py @@ -0,0 +1,20 @@ +student1 = {'语文': 91, '数学': 88, '英语': 85} +student2 = {'语文': 97, '数学': 98, '英语': 90} +student3 = {'语文': 95, '数学': 100, '英语': 93} +score = {'悟空': student1, '诺依': student2, '小贝': student3} + +while True: + print("请输入要查询的名字,退出请输入q") + name = input("姓名:") + print("*" * 30) + if name in score: + info = score[name] + for k,v in info.items(): + print(k, v) + print("*" * 30) + elif name == "q": + break + else: + print("查询错误,请重新输入") + print("*"*30) +print("程序结束") \ No newline at end of file diff --git a/diy2.py b/diy2.py deleted file mode 100644 index 97da545..0000000 --- a/diy2.py +++ /dev/null @@ -1,5 +0,0 @@ -score = {'语文':91,'数学':88,'英语':85} - -# 请对字典进行遍历,将保存的分数以键值对的形式提取打印出来 -for k,v in score.items(): - print(K,V) -- libgit2 0.25.0