美文网首页
Python Challenge[28]

Python Challenge[28]

作者: Recgat | 来源:发表于2017-03-03 21:29 被阅读0次

    [Level 28]


    Title: many pairs ring-ring

    RING-RING-RING say it out loud,但没say出什么来。

    green。green.html显示yes! green!。取出G通道的数据,成对相减大多数的绝对值为42,那么搜集绝对值不是42的数值,转换为 ascii 码。

    from PIL import Image
    img = Image.open('bell.png')
    data = [d[1] for d in img.getdata()]
    s = [abs(data[i]-data[i+1]) for i in range(0,len(data),2) if abs(data[i]-data[i+1])!=42]
    print(bytes(s).decode())
    

    得到:

    whodunnit().split()[0] ?

    whodunnit -> "Who [has] done it?" or "Who did it"。Python的作者是Guido van Rossum,所以是guido[Level 29]

    小结

    可以这样取出G通道的数据:
    data = list(im.split()[1].getdata())
    或这样取出绝对值不为42的数据:

    diff = [abs(a - b) for a, b in zip(green[0::2], green[1::2])]
    filtered = list(filter(lambda x: x != 42, diff))
    

    Python Challenge Wiki

    相关文章

      网友评论

          本文标题:Python Challenge[28]

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