python challenge 13-16关 攻略
2016-06-03 12:26
477 查看
第13关
http://www.pythonchallenge.com/pc/return/disproportional.html
点击图片上电话机的5会弹到另一个网页,通过谷歌发现这是一个XML-RPC(XML
Remote Procedure Call,即XML远程方法调用),RPC是Remote
Procedure Call的缩写,即远程方法调用,是一种在本地的机器上调用远端机器上的一个过程(方法)的技术,这个过程也被大家称为“分布式计算”,是为了提高各个分立机器的“互操作性”而发明出来的技术。
这种远程过程调用使用http作为传输协议,xml作为传送信息的编码格式。
Python下的XML-RPC:
(1)类库:xmlrpclib 一般使用在客户端,这个模块用来调用注册在XML-RPC服务器端的函数。
(2)类库:SimpleXMLRPCServer 一般用来服务器端,这个模块用来构造一个最基本的XML-RPC服务器框架。
根据提示,打电话给”evil”,代码如下:
import xmlrpclib
xmlrpc = xmlrpclib.ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php')
print xmlrpc.system.listMethods()
print xmlrpc.system.methodHelp('phone')
print xmlrpc.phone('evil')
输出:
['phone', 'system.listMethods', 'system.methodHelp', 'system.methodSignature', 'system.multicall', 'system.getCapabilities']
Returns the phone of a person
He is not the evil
找真正的evil,这里我真的没看懂别人的攻略。
经过上一题最后一个不是图片的evil4得知,Bert是evil。
print xmlrpc.phone('Bert')
输出:555-ITALY ITALY就是答案。
真的想不通Bert是怎么知道的,evil4图片上显示的是Ity啊啊啊啊啊啊????
第14关
http://www.pythonchallenge.com/pc/return/italy.html
点击wire.png 下载下来一个10000*1的图片。由提示
结合图片可以得到这样一个规律如图所示:
这样一圈一圈的正好能组成一个100*100的图片。下面的代码是一段非常经典的代码,以边界来判断方向。
代码:
# coding=utf-8
__author__ = 'jiangqiaowei'
from PIL import Image
img = Image.open("wire.png")
left, top, right, bottom = 0, 0, 99, 99
x, y = 0, 0 # 起点
dirx, diry = 1, 0 # 控制增长方向
target = Image.new(img.mode, (100, 100)) # 新建一张图片
for i in xrange(10000):
target.putpixel((x, y), img.getpixel((i, 0)))
if dirx == 1 and x == right: # 从向右增长变为向下
dirx, diry = 0, 1
top += 1
elif diry == 1 and y == bottom: # 从向下变为向左
dirx, diry = -1, 0
right -= 1
elif dirx == -1 and x == left: # 从向左变为向上
dirx, diry = 0, -1
bottom -= 1
elif diry == -1 and y == top: # 从向上变为向右
dirx, diry = 1, 0
left += 1
x += dirx
y += diry
target.save("result.png")
结果:
得到cat,输入url跳转到新网页告诉你这只猫叫uzi,再将cat改为uzi过关
第15关
http://www.pythonchallenge.com/pc/return/uzi.html
查看源代码,buy flowers for tomorrow,所以重点应该是明天即1月27日,送花的话可能是生日。再看日历右下角,二月有29号,所以这一年是闰年。并且以1开头6结尾。猜测这一关的目的是让我们学习python的calendar模块。于是谷歌学习之...
代码:
#coding=utf-8
import calendar
import datetime
for year in range(1000, 2000):
# 先判断是否是闰年
if calendar.isleap(year) and datetime.datetime(year, 1, 27).weekday() == 1:
# 一定要注意星期二的weekday()等于的是1!!!!
# 只有1月27日是星期二的闰年才符合要求
# 接着要满足第一数字是1,最后一个数字是6
if year % 10 == 6:
print year
输出:
1176
1356
1576
1756
1976
看另一个提示: he ain’t the youngest, he is the second。所以取1756年,百度1756年1月27日都有哪些名人的生日。得到莫扎特(mozart),过关
第16关
http://www.pythonchallenge.com/pc/return/mozart.html
Let me get this straight,输出每行的像素值,发现每行都有5个连续的195。猜测每行可能都需要重排一下像素,从红线开始。
代码:
# coding=utf-8
from PIL import Image
img = Image.open("mozart.gif")
width, height = img.size
# 通过输出发现每一行都有5个连续的195,将红线移到最左边
for y in range(height):
colors = [img.getpixel((x, y)) for x in range(width)]
start = colors.index(195) # 找到红线最开始出现的位置
# 重组这一组的颜色
colors = colors[start:] + colors[:start]
for x in range(width):
img.putpixel((x,y), colors[x])
img.save("result.png")
结果:
得到romance, 过关!
大概看了一下第17关,略复杂。暂时不继续做了。按原计划五月结束所有Python语言的学习和练习。
六月第一天,正式开始刷leetcode!
加油!
http://www.pythonchallenge.com/pc/return/disproportional.html
点击图片上电话机的5会弹到另一个网页,通过谷歌发现这是一个XML-RPC(XML
Remote Procedure Call,即XML远程方法调用),RPC是Remote
Procedure Call的缩写,即远程方法调用,是一种在本地的机器上调用远端机器上的一个过程(方法)的技术,这个过程也被大家称为“分布式计算”,是为了提高各个分立机器的“互操作性”而发明出来的技术。
这种远程过程调用使用http作为传输协议,xml作为传送信息的编码格式。
Python下的XML-RPC:
(1)类库:xmlrpclib 一般使用在客户端,这个模块用来调用注册在XML-RPC服务器端的函数。
(2)类库:SimpleXMLRPCServer 一般用来服务器端,这个模块用来构造一个最基本的XML-RPC服务器框架。
根据提示,打电话给”evil”,代码如下:
import xmlrpclib
xmlrpc = xmlrpclib.ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php')
print xmlrpc.system.listMethods()
print xmlrpc.system.methodHelp('phone')
print xmlrpc.phone('evil')
输出:
['phone', 'system.listMethods', 'system.methodHelp', 'system.methodSignature', 'system.multicall', 'system.getCapabilities']
Returns the phone of a person
He is not the evil
找真正的evil,这里我真的没看懂别人的攻略。
经过上一题最后一个不是图片的evil4得知,Bert是evil。
print xmlrpc.phone('Bert')
输出:555-ITALY ITALY就是答案。
真的想不通Bert是怎么知道的,evil4图片上显示的是Ity啊啊啊啊啊啊????
第14关
http://www.pythonchallenge.com/pc/return/italy.html
点击wire.png 下载下来一个10000*1的图片。由提示
结合图片可以得到这样一个规律如图所示:
这样一圈一圈的正好能组成一个100*100的图片。下面的代码是一段非常经典的代码,以边界来判断方向。
代码:
# coding=utf-8
__author__ = 'jiangqiaowei'
from PIL import Image
img = Image.open("wire.png")
left, top, right, bottom = 0, 0, 99, 99
x, y = 0, 0 # 起点
dirx, diry = 1, 0 # 控制增长方向
target = Image.new(img.mode, (100, 100)) # 新建一张图片
for i in xrange(10000):
target.putpixel((x, y), img.getpixel((i, 0)))
if dirx == 1 and x == right: # 从向右增长变为向下
dirx, diry = 0, 1
top += 1
elif diry == 1 and y == bottom: # 从向下变为向左
dirx, diry = -1, 0
right -= 1
elif dirx == -1 and x == left: # 从向左变为向上
dirx, diry = 0, -1
bottom -= 1
elif diry == -1 and y == top: # 从向上变为向右
dirx, diry = 1, 0
left += 1
x += dirx
y += diry
target.save("result.png")
结果:
得到cat,输入url跳转到新网页告诉你这只猫叫uzi,再将cat改为uzi过关
第15关
http://www.pythonchallenge.com/pc/return/uzi.html
查看源代码,buy flowers for tomorrow,所以重点应该是明天即1月27日,送花的话可能是生日。再看日历右下角,二月有29号,所以这一年是闰年。并且以1开头6结尾。猜测这一关的目的是让我们学习python的calendar模块。于是谷歌学习之...
代码:
#coding=utf-8
import calendar
import datetime
for year in range(1000, 2000):
# 先判断是否是闰年
if calendar.isleap(year) and datetime.datetime(year, 1, 27).weekday() == 1:
# 一定要注意星期二的weekday()等于的是1!!!!
# 只有1月27日是星期二的闰年才符合要求
# 接着要满足第一数字是1,最后一个数字是6
if year % 10 == 6:
print year
输出:
1176
1356
1576
1756
1976
看另一个提示: he ain’t the youngest, he is the second。所以取1756年,百度1756年1月27日都有哪些名人的生日。得到莫扎特(mozart),过关
第16关
http://www.pythonchallenge.com/pc/return/mozart.html
Let me get this straight,输出每行的像素值,发现每行都有5个连续的195。猜测每行可能都需要重排一下像素,从红线开始。
代码:
# coding=utf-8
from PIL import Image
img = Image.open("mozart.gif")
width, height = img.size
# 通过输出发现每一行都有5个连续的195,将红线移到最左边
for y in range(height):
colors = [img.getpixel((x, y)) for x in range(width)]
start = colors.index(195) # 找到红线最开始出现的位置
# 重组这一组的颜色
colors = colors[start:] + colors[:start]
for x in range(width):
img.putpixel((x,y), colors[x])
img.save("result.png")
结果:
得到romance, 过关!
大概看了一下第17关,略复杂。暂时不继续做了。按原计划五月结束所有Python语言的学习和练习。
六月第一天,正式开始刷leetcode!
加油!
相关文章推荐
- 小强IT游记之新疆行
- python challenge 0-6关 攻略
- python把字典转换成json字符串
- python-module 'pymysql' has no attribute 'connect'
- 解决在Windows server 2008 安装Python2.7版本
- numpy常用函数
- Python configparser模块
- python urllib2
- python爬虫基础A
- python中的@符号的作用
- python 基本语法
- Python NLTK学习
- PYTHON 自定义异常类的使用
- Python的静态方法和类方法有什么区别
- Python 输出文字带颜色
- 命令形式新建第一个python 项目
- Python函数式练习
- 小强IT游记之大连行
- adaboost算法
- 小强IT游记之厦门行