猫史档案馆


【人 类 迷 惑】把Python代码转成中文

用户:不吃谷立省100w不吃谷立省100w查看:1 回复:1 评论:1 创建时间:2020-07-05T21:13:08


原帖:https://shequ.codemao.cn/community/311838

<form id="myform" action="getTranslate.php" method="post" name="myform"> 代码翻译: 从PIL导入Image,ImageDraw

喵matplotlib。pyplot作为plt

宽度,高度= (60 60)

name1 =输入(“请输入待处理文件的文件名(包括格式):”)

img = Image.open (name1) .convert (L) .resize((宽度、高度))

plt.rcParams [“image.cmap”] = "灰色"

ASCII_HIGH = " $ 8 wm @B % # * oahkbdpqwmZO0QLCJUYXzcvunxrjft / \ |(1){}[] ? _ + ~ < >我!我,:,\“^”。'''

txt = " "

对于范围内的y(高度):

对于x在范围(宽度):

pos = (x, y)

灰色= img.getpixel (pos)

指数= int(灰色/ 256 * 70)

txt += ASCII_HIGH[索引]+"

txt + = " \ n "

 

张开(“处理结果. txt”,“w”) f:

f.write (txt)

img_new = Image.new (“RGB(宽* 12,高* 15),“白色”)

画= ImageDraw.Draw (img_new)

draw.text ((0, 0), txt,填补=“黑色”)

plt.imshow (img_new)

plt.show ()

(翻译:我黑化了emotion_doge

 

 

</form>


回复

上一页1 页 / 共 1下一页
不吃谷立省100w不吃谷立省100w

自古沙发归作者

点赞0


评论