Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson1_4
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
7bc058ce
authored
May 07, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
623fb1a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
star.py
star.py
View file @
7bc058ce
"""
请使用turtle模块画出五角星
"""
import
random
import
turtle
screen
=
turtle
.
Screen
()
screen
.
bgcolor
(
'green'
)
pen
=
turtle
.
Pen
()
colors
=
[
'red'
,
'yellow'
,
'blue'
]
#私钥
key
=
'2010我家庭生活的开始!¥#@'
#实现交互效果,需要加密的语句或输入你想要加密的文字
message
=
screen
.
textinput
(
'温馨提示'
,
'你想要加密的文字?'
)
#加密后的语句
key_message
=
''
#加入的干扰符
noise
=
'@#$^&**'
#加密过程
for
i
in
message
:
str1
=
i
str2
=
random
.
choice
(
key
)
str3
=
random
.
choice
(
key
)
#加密后的信息是由一个需要加密的字加上随机出现在秘钥里面的两个字组成
text
=
str1
+
str2
+
str3
#新信息要自增
key_message
=
key_message
+
text
#把加密后的文字变更成为列表格式
list_message
=
list
(
key_message
)
#获取列表的随机索引
index
=
random
.
randint
(
0
,
len
(
list_message
))
#随机位置插入干扰信息
list_message
.
insert
(
index
,
noise
)
#由此产生新的加密信息,为列表格式,转换成字符串
result_message
=
''
.
join
(
list_message
)
#打印新的机密信息
#print(result_message)
pen
.
up
()
pen
.
goto
(
-
220
,
198
)
pen
.
write
(
result_message
,
font
=
(
'Times'
,
20
,
'normal'
))
pen
.
hideturtle
()
turtle
.
done
()
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