[Python Challenge] - Q7

Q7: smarty

 

http://www.pythonchallenge.com/pc/def/oxygen.html

 

网页只有一张图片,答案在图片中间的那一条灰度。

 

PS:Python没有自己的图片处理模块需要安装PIL。

 

代码:

>>> #Editor: IDLE >>> import Image >>> import sys >>> img = open ('oxygen.png') >>> row = [] >>> img = Image.open ('oxygen.png') >>> for i in range(0,img.size[0],7): row.append(img.getpixel((i,45))) >>> ans = [] >>> for r,g,b,a in row: if r == g == b: ans.append(r) >>> for a in ans: sys.stdout.write (chr(a)) smart guy, you made it. the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121] >>> for s in [105, 110, 116, 101, 103, 114, 105, 116, 121]: sys.stdout.write (chr(s)) integrity >>> #End

你可能感兴趣的:(Python)