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
8639290a
authored
Jul 08, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
b7498cbe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
1 deletions
demo.py
diy3.py
dvojfdi.py
demo.py
0 → 100644
View file @
8639290a
dict
=
{
"name"
:
"小明"
,
"age"
:
"12"
,
"name"
:
"小齐"
}
print
(
dict
[
'name'
])
fruit
=
{
"苹果"
:
"4.98"
,
"葡萄"
:
"9.80"
,
"哈密瓜"
:
"3.50"
}
fruit
.
clear
()
print
(
fruit
)
info
=
{
"name"
:
"创造师"
,
"age"
:
13
,
"course"
:
"python"
}
for
i
in
info
.
values
():
print
(
i
)
\ No newline at end of file
diy3.py
View file @
8639290a
student1
=
{
'语文'
:
91
,
'数学'
:
88
,
'英语'
:
85
}
student1
=
{
'语文'
:
91
,
'数学'
:
88
,
'英语'
:
85
}
student2
=
{
'语文'
:
97
,
'数学'
:
98
,
'英语'
:
90
}
student2
=
{
'语文'
:
97
,
'数学'
:
98
,
'英语'
:
90
}
student3
=
{
'语文'
:
95
,
'数学'
:
100
,
'英语'
:
93
}
student3
=
{
'语文'
:
95
,
'数学'
:
100
,
'英语'
:
93
}
score
=
{
'悟空'
:
student1
,
'诺依'
:
student2
,
'小贝'
:
student3
}
score
=
{
'悟空'
:
student1
,
'诺依'
:
student2
,
'小贝'
:
student3
}
...
...
dvojfdi.py
View file @
8639290a
student1
=
{
'语文'
:
91
,
'数学'
:
88
,
'英语'
:
85
}
student2
=
{
'语文'
:
97
,
'数学'
:
98
,
'英语'
:
90
}
student3
=
{
'语文'
:
95
,
'数学'
:
100
,
'英语'
:
93
}
score
=
{
'悟空'
:
student1
,
'诺依'
:
student2
,
'小贝'
:
student3
}
while
True
:
# 第一步:要取出学生名字对应的成绩字典
print
(
"录入学生姓名,按q键退出!"
)
name
=
input
(
"录入查询的学生姓名:"
)
# 第二步:通过遍历来取出该同学的各科成绩
if
name
in
score
:
info
=
score
[
name
]
print
(
"*"
*
30
)
for
k
,
v
in
info
.
items
():
print
(
k
,
v
)
print
(
"*"
*
30
)
# 第三步:当用户录入错误时,应该如何反馈信息给用户
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