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
0b5d900d
authored
Sep 27, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
b6b42992
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
12 deletions
diy1.py
diy2.py
diy3.py
diy4.py
sum.py
diy1.py
View file @
0b5d900d
students
=
[
"悟空"
,
"小贝"
,
"八戒"
,
"波奇"
]
# 八戒因为要回老家,转学了,请将八戒从班级列表名单中删除
students
.
pop
(
2
)
# 班上来了一个新同学,名叫"诺依",请将"诺依"加入到班级名单里面
students
.
insert
(
0
,
"诺伊"
)
# 班上准备开始辩论赛,分为红(red)、蓝(blue)组,
# 请用切片将班级列表的前2名加入到红组,后2名加入到蓝组
red_team
=
students
[:
2
]
blue_team
=
students
[
2
:]
print
(
"红队:"
+
red_team
)
print
(
blue_team
)
diy2.py
View file @
0b5d900d
message
=
"诺依,周末一起去看动漫展吧!"
# 请对message进行遍历,取出所有元素
...
...
@@ -10,6 +9,12 @@ message = "诺依,周末一起去看动漫展吧!"
# 需要进行加密的语句
message
=
"诺依,周末一起去看动漫展吧!"
# 请对message进行遍历,取出所有元素
length
=
len
(
message
)
i
=
0
while
i
<
length
:
element
=
message
[
i
]
print
(
element
)
i
+=
1
...
...
diy3.py
View file @
0b5d900d
import
random
# 私钥
key
=
"abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!"
# 要加密语句
message
=
"诺依,周末一起去看动漫展吧!"
key_mes
=
""
# 请使用私钥key,对message进行加密
for
i
in
message
:
str1
=
i
#取出密语
str2
=
random
.
choice
(
key
)
#取出私钥
str3
=
random
.
choice
(
key
)
#取出私钥
text
=
str1
+
str2
+
str3
#拼接密语
key_mes
=
key_mes
+
text
#保留完整密语
print
(
key_mes
)
\ No newline at end of file
diy4.py
View file @
0b5d900d
import
random
# 私钥
key
=
"abcdefgh使用python实现简单的位移替换加密,制作密码机关真是太好玩了哈哈哈!"
key
=
input
(
"请输入密文:)
# 要加密语句
message = "
诺依,周末一起去看动漫展吧!
"
# 最终加密后的语句
...
...
@@ -15,7 +15,11 @@ for i in message:
text
=
str1
+
str2
+
str3
key_message
=
key_message
+
text
list_message
=
list
(
key_message
)
list_message
.
insert
(
5
,
noise
)
result_message
=
""
.
join
(
list_message
)
print
(
result_message
)
#转化为列表
list_mes
=
list
(
key_message
)
index
=
random
.
randint
(
0
,
len
(
key_message
))
#插入,进行二次加密
list_mes
.
insert
(
index
,
noise
)
#进行拼接
res
=
""
.
join
(
list_mes
)
print
(
res
)
sum.py
View file @
0b5d900d
...
...
@@ -22,8 +22,6 @@ for i in message:
print
(
i
)
# message = "诺依,周末一起去看动漫展吧!"
# 请使用索引的知识,取出message所有元素(不用遍历的方式)
...
...
@@ -64,7 +62,6 @@ print(key_message)
import
random
# 私钥
key
=
"abcdefgh使用python实现简单的位移替换加密,制作密码机关真是太好玩了哈哈哈!"
# 要加密语句
...
...
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