Ross Wan's World!

Python, Ajax, PHP and Linux.

The Python Challenge Lv.7

Posted by Ross Wan 于 2011/08/31


打开网页,显示的是一张河岸的图片, 特别的是, 图片中央有一细条”灰色带”.将图片另存为”oxygen.png”, 用图片编辑器打开, 放大到最大的倍数.可以看到,那色带是一长方形的灰度色带(left: 0px, top: 43px, right: 607px, bottom: 51px), 它又是由大小为7px * 9px的小长方形灰度块(除了第1块是 5px * 9px)组成的. 灰度的值是0~255, 正好跟 Ascii 相对应, 思路出来了, 下面交给 Python 来处理:

from PIL import Image

if __name__ == '__main__':
    img ='oxygen.png')
    for p in range(4, 607, 7):
        print(chr(int(sum(img.getpixel((p,43))[:3])/3)), end='')

注意, 处理图片需要用到 PIL 库, Python 3的 Windows 编译版可以到以下网址下载:


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

可知要对 “[105, 110, 116, 101, 103, 114, 105, 116, 121]”进行映射就得到答案了;现将上面的代码改写,一次性的得到答案:)

from PIL import Image
import re

if __name__ == '__main__':
    img ='oxygen.png')
    map_string = ''.join(map(lambda p: chr(int(sum(img.getpixel((p, 43))[:3])/3)), range(4, 607, 7)))
    print('\nKey Words: ', end='')
    for i in re.finditer(r'\d+', map_string):
        print(chr(int(, end='')


Key Words: integrity


Have fun :)



Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: