在MISC题目中,它给出了一个由01数字串组成的序列,这个序列的长度是某个整数的平方(例如25的平方是625)。这个序列有可能表示一个正方形像素图,其中每个数字可能表示黑色或白色像素。为了解决这个问题,使用Python3中的PIL库中的Image模块,将01数字串转换成二维码。
from PIL import Image
MAX = 25
pic = Image.new("RGB",(MAX, MAX))
str = "0000000101111110010000000011111010110001101011111001000101001101000101000100100010100010110010100010010001011001010111010001001111101000111111101111100000000101010101010000000111111111100101011111111100110001110100111110100000011101101111001110110101001110001001111000011101110101011001101001001110001010100011101001010001000000100100101011010110111111000101011000010111111111100001000001010001111010001100011101001100000000011111111001110000111001010000000111011111010100011011111010101010001110101001000101010010000000010000100010111110111101100110010001011100000100111010101111101000010111000010010000000101010010001010000"
i = 0
for y in range (0,MAX):
for x in range (0,MAX):
if(str[i] == '1'):
pic.putpixel([x,y],(0, 0, 0))
else:
pic.putpixel([x,y],(255,255,255))
i = i+1
pic.show()
pic.save("flag.png")
得到二维码,扫码获得flag
© 版权声明
吾爱博客|AYFRE.COM 版权所有,转载请标明出处。
THE END
请登录后查看评论内容