用户:
BelugaXiao查看:0 回复:0 评论:0 创建时间:2021-07-18T18:39:38
【作品展示】

【作品介绍】
喵
【作品源代码】
from PIL import Image
import matplotlib.pyplot as plt
# img=Image.open("bcm.jpg")
# img=img.convert("L")
width, height = (60, 60)
img = Image.open('bcm.jpg').convert("L").resize((width, height))
plt.rcParams["image.cmap"]="gray"
# plt.imshow(img)
# plt.show()
ASCII_HIGH = '''$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. '''
txt=""
for y in range(width):
for x in range(height):
pos=(x,y)
gray=img.getpixel(pos)
index=int(gray/256*70)
txt+=ASCII_HIGH[index]
txt+='\n'
print(txt)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn