Commit 24bab9db by BellCodeEditor

auto save

parent 23942e1b
Showing with 30 additions and 24 deletions
students = ["悟空", "小贝", "八戒", "波奇"] students = ["悟空", "小贝", "八戒", "波奇"]
# 八戒因为要回老家,转学了,请将八戒从班级列表名单中删除 # 八戒因为要回老家,转学了,请将八戒从班级列表名单中删除
students.pop(2)
# 班上来了一个新同学,名叫"诺依",请将"诺依"加入到班级名单里面 # 班上来了一个新同学,名叫"诺依",请将"诺依"加入到班级名单里面
students.append("诺伊")
# 班上准备开始辩论赛,分为红(red)、蓝(blue)组, # 班上准备开始辩论赛,分为红(red)、蓝(blue)组,
# 请用切片将班级列表的前2名加入到红组,后2名加入到蓝组 # 请用切片将班级列表的前2名加入到红组,后2名加入到蓝组
red_team = students[:2]
students.pop(2)
students.append("诺伊")
print(students)
red_team = students[0:2]
blue_team = students[-2:] blue_team = students[-2:]
print(red_team) print(red_team)
print(blue_team) print(blue_team)
...@@ -18,3 +14,5 @@ print(blue_team) ...@@ -18,3 +14,5 @@ print(blue_team)
message = "诺依,周末一起去看动漫展吧!" message = "诺依,周末一起去看动漫展吧!"
# 请对message进行遍历,取出所有元素 # 请对message进行遍历,取出所有元素
# i = 0
# while i < len(message):
# ele = message[i]
# print(ele)
# i+=1
for i in message: for i in message:
print(i) print(i)
i=0
while i < len(message):
e = message[i]
print(e)
i+=1
...@@ -51,3 +53,4 @@ message = "诺依,周末一起去看动漫展吧!" ...@@ -51,3 +53,4 @@ message = "诺依,周末一起去看动漫展吧!"
import random import random
# 私钥 # 私钥
key = "abcdefgh使用编程实现位移替换加密,制作密码机关真是太好玩了哈哈!" key = input("")
# 要加密语句 # 要加密语句
message = "诺依,周末一起去看动漫展吧!" message = "诺依,周末一起去看动漫展吧!"
noice="iwuergfbdjgaekyt akhg "
#一次加密
key_mes = "" key_mes = ""
noi_mes = "4903uythiegurqmvy8gh4urtshgs2345344"
for i in message: for i in message:
str1 = i s1 = i
str2 = random.choice(key) s2 = random.choice(key)
str3 = random.choice(key) s3 = random.choice(key)
text = str1+str2+str3 text = s1+s2+s3
key_mes = key_mes+text key_mes = key_mes+text
print(key_mes) print(key_mes)
#转化为列表 #二次加密,转化为列表
list_mes = list(key_mes) list_mes = list(key_mes)
index = random.randint(0,len(key_mes))
#列表的插入 #列表的插入
list_mes.insert(index,noi_mes) #随机加入
# print(list_mes) index = random.randint(0,len(list_mes))
#拼接为字符串 list_mes.insert(index,noice)
#再拼接为字符串
res_mes = "".join(list_mes) res_mes = "".join(list_mes)
print(res_mes) print(res_mes)
...@@ -34,3 +35,6 @@ print(res_mes) ...@@ -34,3 +35,6 @@ print(res_mes)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment