Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson9_3
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d6466c62
authored
May 05, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
e7aeaf76
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
2 deletions
diy3.py
diy3.py
View file @
d6466c62
...
...
@@ -4,7 +4,39 @@ student3 = {'语文': 95, '数学': 100, '英语': 93}
score
=
{
'悟空'
:
student1
,
'诺依'
:
student2
,
'小贝'
:
student3
}
name
=
input
(
"名字:"
)
'''
###方法一###
# for m in score:
# if m == name :
# print(score[m])
####方法二####
for m , n in score.items():
if m == name:
print(m,n)
'''
while
True
:
print
(
'请在下列输入框中输入名字,退出请输入q'
)
name
=
input
(
"名字:"
)
#判断输入名字是否在字典中
if
name
in
score
:
print
(
'*'
*
10
)
#提取对应姓名的分数
b
=
score
[
name
]
#提取键、值
for
k
,
v
in
b
.
items
():
print
(
k
,
v
)
print
(
'*'
*
10
)
elif
name
==
"q"
:
break
else
:
print
(
"输入姓名有误,请重新输入"
)
# 查询并打印出输入的名字对应的所有科目的成绩
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment