Commit a09d11a9 by BellCodeEditor

auto save

parent 726ca779
#导入模块
from PIL import Image
import matplotlib.pyplot as plt
import os
img=os.listdir("images")#导入图片
images2=[]
#图片加入列表
for i in img:
img3=Image.open("images/"+i)
images2.append(img3)
aaaa=[[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0],
[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
row=20
col=20
bg=Image.new('RGB',(row*160,col*160),"white")#创建空白背景
#图片插入空白背景
index=0
for y in range(row):
for x in range(col):
if aaaa[y][x]==1:
bg.paste(images2[index%len(images2)],(x*160,y*160))
index+=1
#显示图片
plt.imshow(bg)
plt.show()
\ No newline at end of file
# 古代测量臂力是靠不同重量的石锁,只能测整数哦。
# 最小的石锁是30公斤最大的石锁是100公斤,注意输入的数字哦。
# 请优化刚刚的代码,并增添交互效果,和自动输出最强三人信息的功能~
# 问询处
# 归档处
hero=['赵一',30,'丁二',37,'孙五',52,'王猛',89,'周亮',98,'张宇',100]
for i in range(len(hero)):
# 打印出臂力最强的三个人和他们对应的臂力值:
from PIL import Image
import os
color_list=["red","green","yellow"]
if not os.path.exists("纯色图片"):
os.mkdir("纯色图片")
for i in range(len(color_list)):
im=Image.new("RGB",(640,480),color_list[i])
im.save(f"纯色图片/{color_list[i]}.png")
\ 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