Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson7_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
d80dd5ce
authored
May 19, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
30cb799c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
18 deletions
diy2.py
diy2.py
View file @
d80dd5ce
# 序列拆包:右侧一个序列,左侧多个遍历
# 需要进行加密的语句
tuple_surname
=
"黄"
,
"孙"
,
[
"红"
,
"黄"
,
"绿"
]
message
=
"诺依,周末一起去看动漫展吧!"
print
(
type
(
tuple_surname
))
# 请对message进行遍历,取出所有元素
a
,
b
,
c
=
tuple_surname
for
i
in
message
:
print
(
a
,
b
,
c
)
# "黄", "孙", "钱"
# print(i)
print
(
type
(
c
))
print
(
i
,
end
=
" "
)
# added by hg
list_color
=
[[
"红"
,
"黄"
,
"绿"
],
"黄"
,
"绿"
]
a
,
b
,
c
=
list_color
print
(
a
,
b
,
c
)
# "红", "黄", "绿"
print
(
type
(
a
))
a
,
b
,
c
=
"[1,2,3]禄寿"
print
(
a
,
b
,
c
)
# "福", "禄", "寿"
print
(
type
(
a
))
# 变量交换:a,b=b,a
name01
=
"小华"
name02
=
"小明"
name01
,
name02
=
name02
,
name01
# 相当于序列拆包的 name01,name02 = (name02, name01)
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