- # 请在此添加代码
- ########## Begin ##########
-
-
- from PIL import Image #导入PIL库中的Image模块
- im = Image.new("RGB", (128, 128), "red") #新建图像
- #im.show() #显示图像
- im.save("/data/workspace/myshixun/src/step1/pic2/pic2.jpg") #保存图像文件
- #以下代码是查看保存下来的图像
- im2 = Image.open("pic2.jpg") #打开图像文件
- im2.show() #显示原图
-
- ########## End ##########
- s = input("请输入明文:")
- n = int(input("请输入移位数:"))
- # 请在此添加代码
- ########## Begin ##########
-
- t = "" # t 表示密文
- for c in s: # 对明文中的每个字符都进行移位的操作
- t=t+chr(ord(c)+n)
-
-
-
- ########## End ##########
-
- print(f"原文为:{s} 密文为:{t}")
- from PIL import Image
- from matplotlib import pyplot as plt
-
- # 生成红色图像
- image_1 = Image.new("RGB", (300, 300), &#