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
a6fe249f
authored
Aug 08, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
027d3568
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
diy1.py
diy2.py
diy3.py
diy1.py
0 → 100644
View file @
a6fe249f
diy2.py
View file @
a6fe249f
message
=
"诺依,周末一起去看动漫展吧!"
message
=
"诺依,周末一起去看动漫展吧!"
#干扰字符
# 请对message进行遍历,取出所有元素
# 请对message进行遍历,取出所有元素
# for i in message:
# print(i)
# # 如何通过索引便利
# i = 0
# while i < len(message):
# print(message[i])
# i += 1 # i = i + 1 , i -= 1 , i *= 1 , i /= 1
diy3.py
0 → 100644
View file @
a6fe249f
import
random
#导入模块
message
=
"诺依,周末一起去看动漫展吧!"
#干扰字符
key
=
'啊是的服务人群而退哦iui于太原人忒热尔头晕头痛!$
%
^&*(&^
%
TREdsdFDGHTYU&86q34rwfgstytui)'
#添加新的干扰字符:
new_key
=
'!@#$
%
^'
text
=
''
#创建空字符串
for
i
in
message
:
#便利字符串
str1
=
random
.
choice
(
key
)
#随机从字符串中取出元素
str2
=
random
.
choice
(
key
)
text
=
text
+
str1
+
str2
+
i
#把随机取出来的字符串与我们遍历的语句进行拼接
#列表里面的方法 列表名.insert(索引,元素)
#把字符串转成列表
list1
=
list
(
text
)
num
=
random
.
randint
(
0
,
len
(
list1
))
#生成一个随机数
list1
.
insert
(
num
,
new_key
)
#把列表转成字符串
str
=
''
.
join
(
list1
)
print
(
str
)
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