使用python 3.x 对pythonchallenge-----7的解答过程

pythonchallenge-7地址 : http://www.pythonchallenge.com/pc/def/oxygen.html
图片如下:


题目解析:对图片中的乱码部分进行解析,得出颜色值,然后转换为字母

解题过程:
from PIL import Image
img = Image.open(r'./other/oxygen.png')
print(img.format, img.size, img.mode)

li = []
chrli = []
for i in range(629):
    data = img.getpixel((i,46))
    if data[0] == data[1] == data[2]:
        li.append(data[0])

for zzz in li[::7]:
    chrli.append(chr(zzz))

print("".join(chrli))

source = [105, 110, 116, 101, 103, 114, 105, 116, 121]
print("".join(chr(n) for n in source))

答案:integrity

smart guy, you made it. the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]
integrity

 心得:

这关使用了第三方库PIL

 
 
原文地址:https://www.cnblogs.com/yinsjun/p/7473916.html