第五关:
ok,进入到第五关,关卡长这个样子。。。。
还让我们"pronounce it "这什么意思啊实在没看懂。
在网页源代码里面显示如下图:
到底怎么才能理解作者这清奇的脑回路呢?
好吧,经过一番查询,我才明白过来,居然是让我们根据发音得到pickle这一信息,然后用pickle处理数据。。。。。
这谁能想出来啊喂,,,
不管怎么说,利用pickle处理banner.p这个文件应该就能解决问题了吧。
import pickle
file = open("E:/PycharmProjects/python_challenge/banner.p", "rb")
data = pickle.load(file)
for list in data:
for item in list:
print(item[0]*item[1], end='')
print('')
得到结果:
于是进入第六关:http://www.pythonchallenge.com/pc/def/channel.html
第六关:
查看源码:
<html> <!-- <-- zip -->
<head>
<title>now there are pairs</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<center>
<img src="channel.jpg">
<br/>
其中的“ZIP”完全是多余的,明显是提示
将连接改为http://www.pythonchallenge.com/pc/def/channel.zip
能够下载一个压缩包,这个压缩包很可能是解题的关键。
import zipfile
file_zip = zipfile.ZipFile('E:\PycharmProjects\python_challenge\channel (1).zip')
files = file_zip.namelist()
def item(start):
if start in files:
with file_zip.open(start) as f:
content = str(f.read())[2:-1]
print(content)
result = '{}.txt'.format(content.split(' ').pop())
print("result:",result)
return item(result)
else:
result = start.split('.')
print('The result is: ', result[0])
if __name__ == '__main__':
item('90052.txt')
运行代码,得到结果为:
。。。。
result: 91038.txt
Next nothing is 44221
result: 44221.txt
Next nothing is 992
result: 992.txt
Next nothing is 8700
result: 8700.txt
Next nothing is 45100
result: 45100.txt
Next nothing is 68628
result: 68628.txt
Next nothing is 67824
result: 67824.txt
Next nothing is 46145
result: 46145.txt
Collect the comments.
result: comments..txt
The result is: comments
最后得到结果是comments,试了几次之后,查询到zipfile有个comment属性,修改代码:
import zipfile
file_zip = zipfile.ZipFile('E:\PycharmProjects\python_challenge\channel (1).zip')
files = file_zip.namelist()
lst = []
def item(start):
if start in files:
with file_zip.open(start) as f:
content = str(f.read())[2:-1]
com = str(file_zip.getinfo(start).comment)[2:-1]
print("com:",com)
lst.append(com)
print(content)
result = '{}.txt'.format(content.split(' ').pop())
return item(result)
else:
result = start.split('.')
print('The result is: ', result[0])
if __name__ == '__main__':
item('90052.txt')
result = ''.join(lst)
for item in result:
if item == '\n':
print()
else:
print(item)
for i in lst:
if i == '\\n':
print()
else:
print(i,end = '')
得到结果为:
那么简单了,访问:http://www.pythonchallenge.com/pc/def/hockey.html
得到新的提示:it's in the air. look at the letters.
哦。。。字母里面是OXYGEN,那么试试http://www.pythonchallenge.com/pc/def/oxygen.html好不好用。。
果然进入下一关。。。。