Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-2
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
6fa16717
authored
Jul 24, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
62cad33d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
class.py
class2.py
class.py
0 → 100644
View file @
6fa16717
#1,创建一个字典name,
#2.查询王五的年龄
#修改,
#3.增加小明,16岁在字典里
'''
创建一个字典dict={键值对}
查询字典,通过建查询dict["键"]
修改 ,通过建,修改值,,,,name["键"]=40
增加一个键值对,dict["键"]=值
删除1 name.pop("键")
2 del name
3 name.clear()
遍历
1遍历所有的键
for i in dict.keys():
2遍历所有的值
for i in dict.values():
3遍历所有的键值
for k,v in dict.items():
'''
name
=
{
"张三"
:
29
,
"李四"
:{
"年龄"
:
25
,
"性别"
:
"男"
,
"成绩"
:
90
},
"王五"
:
39
,
"赵六"
:
40
}
lisi_name
=
name
[
"李四"
]
for
k
,
v
in
lisi_name
.
items
():
print
(
k
,
v
)
\ No newline at end of file
class2.py
0 → 100644
View file @
6fa16717
def
test1
():
a
=
5
b
=
2
c
=
4
a
+
b
def
test2
():
q
=
3
e
=
5
a
+
b
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