Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson6-1
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
657efdd6
authored
Mar 03, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
26b3b1d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
14 deletions
diy.py
diy.py
View file @
657efdd6
# 和你的小伙伴用列表讲讲桃园结义的故事,并说说这其中运用了哪些列表知识:
# # a='to be or not to be that is a question'
# 来,我给你起个头~
# # a=a.split(' ')
# 从前啊,有三个bro,分别是:刘备、关羽、张飞...
# # b={}
bro1
=
"关羽"
# # for i in range(len(a)):
bro2
=
"刘备"
# # b[a[i]]=1
bro3
=
"张飞"
# # if a[i] in b:
bros
=
[
"刘备"
,
"关羽"
,
"张飞"
]
# # b[a[i]]+=1
bro1
=
[
"关羽"
,
160
,
8.5
]
# # print(b)
bro2
=
[
"刘备"
,
161
,
9.1
]
bro3
=
[
"张飞"
,
166
,
8.3
]
bros
[
0
]
=
"关羽"
bros
[
1
]
=
"刘备"
print
(
bros
)
\ No newline at end of file
# # string = "to be or not to be that is a question"#定义变量存储字符串
# # lis=string.split(" ")#使用分割函数将字符串转为列表
# # count={}#定义一个空字典
# # for x in lis:#遍历列表
# # # if x not in count:#判断列表元素是否在字典中
# # # count[x]=1
# # # else:
# # # count[x]+=1
# # # print(count)#打印字典
# # # a=80
# # # b=70
# # # if a>b:
# # # a,b=b,a
# # # print(a,b)
# # tuple1 = (1,2,3)
# # tuple2 = (2,)
# # print(type(tuple2))
# # print(tuple1*tuple2)
# d={'1':1,'2':2,'3':3,'4':4}
# b=d
# print(b)
# print(d)
# b['2']=5
# print(d)
# print(b)
# print(d['2']+b['2'])
# a=list(range(10))
# a[:2]=[5]
# print(a)
# a.pop(5)
# print(a)
# a.remove(5)
# print(a)
# a="to be or not to be that is a question"
# a=a.split(' ')
# b={}
# for i in range(len(a)):
# if a[i] not in b:
# b[a[i]]=1
# else:
# b[a[i]]+=1
# for i in a:
# if i not in b:
# b[i]=1
# else:
# b[i]+=1
# print(b)
# 创建元组:
# 遍历元组,切片输出,元组添加元素:
# 创建单个元素的元组,合并2个元组。
# 返回元组中定值出现的次数,
# 返回一个元素的索引位置:
# 创建列表:
# 实现列表的增,删,多用方式实现:
# 合并2个列表,
# 一个列表追加到另一个列表中,
# 返回列表中定值出现的次数,
# 返回一个元素的索引位置:
# 实现列表降序排列:
# 创建字典:
# 创建一个包含字典的字典,并根据字典内学生数学成绩降序排列;
# 实现字典的增,删,改,
b
=
{
'a'
:
12
,
'c'
:
67
}
a
=
[
{
'b'
:
12
,
'c'
:
67
},
{
'a'
:
123
,
'c'
:
45
},
{
'a'
:
34
,
'c'
:
35
},
{
'a'
:
122
,
'c'
:
15
}
]
def
func
(
e
):
return
e
[
'c'
]
a
.
sort
(
reverse
=
True
,
key
=
func
)
print
(
a
)
# 创建一个集合,
# 集合中添加元素,
# l=['i','love','you','!']
# l='.'.join(l)
# l=l.split('.')
# l=' '.join(l)
# print(l)
t2
=
1
,
2
,
3
print
(
type
(
t2
))
\ 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