美文网首页
Python Challenge[7]

Python Challenge[7]

作者: Recgat | 来源:发表于2017-02-09 13:44 被阅读0次

[Level 7]


Title: smarty

所有地方均无提示,图片中有一条灰色带,或许需要从这突破。图片处理需要pillow模块,第三方PIL库。然而,并没有什么思路,无奈求助谷歌。灰色带宽为43px到51px,长为0px到607px。获取该区间的的像素:

from PIL import Image
img = Image.open('oxygen.png')
for i in range(0,607):
  img.getpixel((i,50))

第四个A值固定是255(表示完全不透明,A表示Alpha,透明度),且每七个为一组返回的像素相同(第一组5个)。ascii码占有255个位置,需要将返回的像素的R(G或B)值转为字符。

target = ''
for i in range(0,607,7):
  target+ = chr(img.getpixel((i,50))[0])
print(target)

显示

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

再次转换print(''.join(chr(i) for i in [105, 110, 116, 101, 103, 114, 105, 116, 121])),得到integrity[Level 8]

小结

  1. Image.getpixel(xy)返回指定位置的像素。

Python Challenge Wiki

  1. 有点强,Image.tobytes(encoder_name='raw', *args)返回图片的字节对象,截取其中的有效字节。

from PIL import Image
print(Image.open('oxygen.png').tobytes()[108188:110620:28])


2. 可以这样打开图片
> ```python
import io,urllib.request
img = Image.open(io.BytesIO(urllib.request.urlopen('http://www.pythonchallenge.com/pc/def/oxygen.png').read()))

More

相关文章

  • Python挑战:00~03关

    Python Challenge Python Challenge 00 网址: http://www.pytho...

  • The Python Challenge(7)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据拉链,得到第一个关键字zip,再继续看源码,有如...

  • Python Challenge[7]

    [Level 7] Title: smarty 所有地方均无提示,图片中有一条灰色带,或许需要从这突破。图片处理需...

  • Python挑战:04-05关

    Python Challenge Python Challenge 04 现在,我们来挑战第四关,从第三关的结果,...

  • Python Challenge_7-11

    07 第七关,好吧,提示:it's in the air. look at the letters.然后鬼知道ho...

  • The Python Challenge(5)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面源码提示: 再点击页面图片显示: 可知是需要...

  • The Python Challenge(8)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 页面和源码中无任何提示,但图片中有一条很明显的灰度线...

  • The Python Challenge(9)

    问题链接 问题链接如下: 答案链接 答案链接如下: 登陆用户名密码为huge和file。 解题思路 阅读源码有如下...

  • The Python Challenge(2)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 将页面给定的字符串根据给定规则进行替换即可,规则如下...

  • The Python Challenge(3)

    问题链接 问题链接如下: 答案链接 答案链接如下: 解题思路 根据页面提示: 阅读源码,有如下内容: 编写代码从中...

网友评论

      本文标题:Python Challenge[7]

      本文链接:https://www.haomeiwen.com/subject/rmmbittx.html