Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson9_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
c667a98f
authored
Jun 19, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d36f911f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
63 additions
and
5 deletions
1.py
2.py/3.py
4.py
5.py
6.py
7.py
8.py
9.py
store.py
1.py
0 → 100644
View file @
c667a98f
s
=
'aabbbccccbbd'
dict2
=
{}
for
i
in
s
:
if
i
not
in
dict2
:
dict2
[
i
]
=
s
.
count
(
i
)
s1
=
''
for
k
,
v
in
dict2
.
items
():
s1
+=
k
+
str
(
v
)
print
(
s1
)
\ No newline at end of file
2.py/3.py
0 → 100644
View file @
c667a98f
s
=
'Welome to Beijing'
s1
=
s
.
split
(
' '
)
s1
.
reverse
()
print
(
' '
.
join
(
s1
))
\ No newline at end of file
4.py
0 → 100644
View file @
c667a98f
str
=
input
(
"请输入一个字符串:
\n
"
)
A
=
""
B
=
""
for
i
in
str
[::
2
]:
A
=
A
+
i
print
(
"下标为偶数的字符串:"
)
print
(
A
)
for
j
in
str
[
1
::
2
]:
B
=
B
+
j
print
(
"下标为奇数的字符串:"
)
print
(
B
)
C
=
A
+
B
print
(
"合并后的字符串:"
)
print
(
C
)
\ No newline at end of file
5.py
0 → 100644
View file @
c667a98f
str1
=
"ayjAYJabcdefghf"
new
=
{}
str2
=
str1
.
lower
()
for
j
in
str2
:
if
j
in
new
:
new
[
j
]
+=
1
else
:
new
[
j
]
=
1
print
(
new
)
\ No newline at end of file
6.py
0 → 100644
View file @
c667a98f
str
=
input
(
"请输入一个字符串:
\n
"
)
str1
=
str
[
0
:
-
1
]
str3
=
str
[
-
1
]
+
str1
print
(
"后移一位的新字符串为:
%
s"
%
str3
)
\ No newline at end of file
7.py
0 → 100644
View file @
c667a98f
list
=
[
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
]
length
=
len
(
list
)
print
(
"字符串中间位置的数字为:
%
s"
%
list
[
int
((
length
-
1
)
/
2
)])
\ No newline at end of file
8.py
0 → 100644
View file @
c667a98f
list
=
[
1
,
1
,
1
,
2
,
2
,
3
,
4
,
4
,
4
,
5
,
5
]
for
i
in
list
:
if
list
.
count
(
i
)
>
1
:
list
.
remove
(
i
)
print
(
"删除重复元素后:
%
s"
%
list
)
\ No newline at end of file
9.py
0 → 100644
View file @
c667a98f
store.py
View file @
c667a98f
goods
=
{
'可口可乐'
:
3
,
'旺仔牛奶'
:
4
,
'农夫山泉'
:
1
,
'辣条'
:
3
,
'巴西烤肉'
:
2
,
'果冻'
:
4
,
'乐事'
:
5
,
'奥利奥'
:
10
,
'巧克力'
:
6
}
goods
.
pop
(
"农夫山泉"
)
print
(
goods
)
s
=
'HelloMyWorld'
str
=
[]
for
i
in
range
(
len
(
s
)):
if
'A'
<=
s
[
i
]
<=
'Z'
and
i
!=
0
:
str
.
append
(
' '
)
str
.
append
(
s
[
i
])
print
(
''
.
join
(
str
))
\ 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