前情回顾:上一篇

第16关地址

打开16关,又是一张奇奇怪怪很多点点的图片,应该又是与PIL库有关的.

页面的标题是:let me get this straight。这是英语中的一句俚语,意思是让我把这事搞清楚.在这一关中其实是让我们把每一行像素位置调整后对其.

看这幅图片,很多红色的点,于是想到是不是这些点的像素有什么特别,将每一行的像素值打印出来后发现每一行都有连续的5个像素的值为195.

然后把每一行的像素移位,像素值195的移到最左边,然后对其就得到了新的图片.如下:

即下一关的url.

代码如下:

 import urllib.request as ur
from PIL import Image def main():
im = Image.open("mozart.gif")
(width,height) = im.size
mode = im.mode
print(mode)
print(im.size) imAnswer = Image.new(mode,(width,height)) for y in range(height):
pixels = [im.getpixel((x,y)) for x in range(width)]
print(pixels) x = pixels.index(195)
newpixels = pixels[x:width] + pixels[:x] for x in range(width):
imAnswer.putpixel((x,y),newpixels[x]) imAnswer.save('16Answer.gif') if __name__ == '__main__':
main()

python challenge 16的更多相关文章

  1. python challenge第1关--NoteBook上的“乱码”

    在 python challenge第0关中已经得到第1关的地址了: http://www.pythonchallenge.com/pc/def/map.html 一.观察地址栏和标签: What a ...

  2. Python Challenge 过关心得(0)

    最近开始用Openerp进行开发,在python语言本身上并没有什么太大的进展,于是决定利用空闲时间做一点python练习. 最终找到了这款叫做Python Challenge(http://www. ...

  3. Python Challenge 第四题

    这一题没有显示提示语,仅仅有一幅图片,图片也看不出什么名堂,于是直接查看源代码,源代码例如以下: <html> <head> <title>follow the c ...

  4. The Python Challenge 谜题全解(持续更新)

    Python Challenge(0-2) The Python Challengehttp://www.pythonchallenge.com/ 是个很有意思的网站,可以磨练使用python的技巧, ...

  5. The Python Challenge 0-4

    The Python Challenge 0-4 项目地址:http://www.pythonchallenge.com/ Level-0 提示Hint: try to change the URL ...

  6. 十六. Python基础(16)--内置函数-2

    十六. Python基础(16)--内置函数-2 1 ● 内置函数format() Convert a value to a "formatted" representation. ...

  7. [ZZ]知名互联网公司Python的16道经典面试题及答案

    知名互联网公司Python的16道经典面试题及答案 https://mp.weixin.qq.com/s/To0kYQk6ivYL1Lr8aGlEUw 知名互联网公司Python的16道经典面试题及答 ...

  8. python challenge答案参考

    Solutions to python challenge. http://garethrees.org/2007/05/07/python-challenge/ https://github.com ...

  9. Python Challenge 第一关

    偶然在网上看到这个,PYTHON CHALLENGE,利用Python语言闯关,觉得挺有意思,就记录一下. 第0关应该算个入口吧,试了好几次才试出来,没什么代码就不写了.计算一个结果出来就行. 第一关 ...

随机推荐

  1. 【转】java参数传递(超经典)

    原文网址:http://blog.sina.com.cn/s/blog_4b622a8e0100c1bo.html Java中的参数传递机制一直以来大家都争论不休,究竟是“传值”还是“传址(传引用)” ...

  2. Codeforces 716B Complete the Word【模拟】 (Codeforces Round #372 (Div. 2))

    B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  3. Contains Duplicate II ——LeetCode

    Given an array of integers and an integer k, find out whether there there are two distinct indices i ...

  4. RAII(Resource Acquisition Is Initialization)资源获得式初始化

    当在编写代码中用到异常,非常重要的一点是:“如果异常发生,程序占用的资源都被正确地清理了吗?” 大多数情况下不用担心,但是在构造函数里有一个特殊的问题:如果一个对象的构造函数在执行过程中抛出异常,那么 ...

  5. poj 1609 dp

    题目链接:http://poj.org/problem?id=1609 #include <cstdio> #include <cstring> #include <io ...

  6. MakePic.com 图片制造 打造个性签名 拒绝垃圾邮件 生成个性印章

    MakePic.com 图片制造 打造个性签名 拒绝垃圾邮件 生成个性印章 欢迎使用MakePic.com

  7. 带你一分钟理解 JavaScript 闭包

    什么是闭包? 先看一段代码: function a(){ var n = 0; function inc() { n++; console.log(n); } inc(); inc(); } a(); ...

  8. E - 食物链 poj1182

    题目告诉有  3  种动物,互相吃与被吃,现在告诉你  m  句话,其中有真有假,叫你判断假的个数  (  如果前面没有与当前话冲突的,即认为其为真话  ).每句话开始都有三个数 D A B,当D = ...

  9. JSTL和select标签的组合使用

    1.用于根据不同的值显示对应的内容,不能选择 <select name="grade"> <c:choose> <c:when test=" ...

  10. MYSQL 体系结构图