Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson7_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
7317e213
authored
Jan 11, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
4277a768
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
6 deletions
55.py
diy1.py
diy2.py
55.py
0 → 100644
View file @
7317e213
import
random
# 私钥
key
=
"abcdefgh使用python实现简单的位移替换加密,制作密码机关真是太好玩了哈哈哈!eainrhg rIOSRHQLYTIWEFIUQWGDIWQ"
# 要加密语句
message
=
"诺依,周末一起去看动漫展吧!"
key_message
=
""
# 最终加密后的语句
for
i
in
message
:
s1
=
i
s2
=
random
.
choice
(
key
)
s3
=
random
.
choice
(
key
)
text
=
s1
+
s2
+
s3
key_message
=
key_message
+
text
print
(
key_message
)
#二次加密
noice
=
"iwe4utbfh ilcn y5389t28435她一定会粉色欧亚高铁无日峰"
#想用insert,转化成list
list_message
=
list
(
key_message
)
#随机进行二次加密
index
=
random
.
randint
(
0
,
len
(
list_message
))
#利用insert方法插入
list_message
.
insert
(
index
,
noice
)
#最终要的是字符串,所以用join()方法
result_message
=
""
.
join
(
list_message
)
print
(
result_message
)
diy1.py
View file @
7317e213
...
@@ -3,13 +3,14 @@ students = ["悟空", "小贝", "八戒", "波奇"]
...
@@ -3,13 +3,14 @@ students = ["悟空", "小贝", "八戒", "波奇"]
# 八戒因为要回老家,转学了,请将八戒从班级列表名单中删除
# 八戒因为要回老家,转学了,请将八戒从班级列表名单中删除
students
.
pop
(
2
)
students
.
pop
(
2
)
# 班上来了一个新同学,名叫"诺依",请将"诺依"加入到班级名单里面
# 班上来了一个新同学,名叫"诺依",请将"诺依"加入到班级名单里面
students
.
insert
(
1
,
"诺依"
)
students
.
append
(
"诺依"
)
# 班上准备开始辩论赛,分为红(red)、蓝(blue)组,
# 班上准备开始辩论赛,分为红(red)、蓝(blue)组,
# 请用切片将班级列表的前2名加入到红组,后2名加入到蓝组
# 请用切片将班级列表的前2名加入到红组,后2名加入到蓝组
red_team
=
students
[:
2
]
red
=
students
[:
2
]
blue_team
=
students
[
2
:]
blue
=
students
[
-
2
:]
print
(
red_team
)
print
(
red
,
blue
)
print
(
blue_team
)
...
...
diy2.py
View file @
7317e213
...
@@ -6,10 +6,13 @@ message = "诺依,周末一起去看动漫展吧!"
...
@@ -6,10 +6,13 @@ message = "诺依,周末一起去看动漫展吧!"
# 请使用索引的知识,取出message所有元素(不用遍历的方式)
# 请使用索引的知识,取出message所有元素(不用遍历的方式)
# 需要进行加密的语句
# 需要进行加密的语句
i
=
0
i
=
0
while
i
<
len
(
message
):
while
i
<
len
(
message
):
element
=
message
[
i
]
element
=
message
[
i
]
print
(
element
)
print
(
element
)
i
+=
1
i
+=
1
...
@@ -37,3 +40,4 @@ while i<len(message):
...
@@ -37,3 +40,4 @@ while i<len(message):
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