Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson9_4
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
5f1c134a
authored
Jun 05, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
6791be70
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
diy3.py
dvojfdi.py
diy3.py
View file @
5f1c134a
...
...
@@ -7,13 +7,18 @@ score = {'悟空': student1, '诺依': student2, '小贝': student3}
# 查询并打印出输入的名字对应的所有科目的成绩
while
True
:
name
=
input
(
"名字:"
)
if
name
in
score
:
a
=
score
[
name
]
print
(
'*'
*
30
)
for
k
,
v
in
a
.
items
():
while
True
:
#无限循环
print
(
"退出请按q"
)
#提示内容
name
=
input
(
"名字:"
)
#获取名字
print
(
'*'
*
30
)
#作为分割线
if
name
in
score
:
#条件判断
info
=
score
[
name
]
#符合条件执行内容
for
k
,
v
in
info
.
items
():
#获取字典中的键值对
print
(
k
,
v
)
break
print
(
'*'
*
30
)
elif
name
==
"q"
:
break
#跳出循环
else
:
print
(
'输入错误'
)
print
(
"*"
*
30
)
print
(
"程序结束"
)
\ No newline at end of file
dvojfdi.py
View file @
5f1c134a
...
...
@@ -10,6 +10,6 @@ score = {'悟空': student1, '诺依': student2, '小贝': student3}
naem
=
input
(
"名字"
)
#获取名字
if
name
in
score
:
#条件判断,这个名字在不在字典中!!!
info
=
score
[
naem
]
input
(
info
)
#
else
:
#
input
(
"您输入的有误,请重新输入!!!"
)
#
\ No newline at end of file
input
(
info
)
else
:
input
(
"您输入的有误,请重新输入!!!"
)
\ No newline at end of file
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