连接:python challenge level 6 url: http://www.pythonchallenge.com/pc/def/channel.html
又是一张毫无头绪的图片,要想到拉链(zip)。对于我来说。实在不知道该怎么办
好吧。。根据前面的经验,看看网页源代码:
有两个提示:
1.
<html> <!-- <-- zip -->
2.
<!-- The following has nothing to do with the riddle itself. I just
thought it would be the right point to offer you to donate to the
Python Challenge project. Any amount will be greatly appreciated.
-thesamet
-->
从上面两个提示。我们知道应该第一个是关键,第二个就是让你赞助的,,,
所以我又百度了。:
原来是将网页URL后缀名改成zip,改完后会下载一个ZIP文件,打开后有一堆的txt文件,线索就在其中的一个readme.txt里:
好吧:打开文件。里面有很多txt文件。最下面有个readme.txt。提示是:
welcome to my zipped list.
hint1: start from 90052
hint2: answer is inside the zip
打开90052.txt,内容是Next nothing is 94191,看来这题是跟第四题一样,找next nothing。
并且需要使用模块zipfile
首先:我们根据前面的提醒写出:
import re
import zipfile
#获得一个zipfile对象
f=zipfile.ZipFile('channel.zip','r')
#获取第一个文件名
name='90052'
file='.txt'
while name :
try:
a=f.read('%s'%(name+file))
name=re.findall(r'\d+',a.decode('utf-8'))[0]
#print(name)
except:
print (name,'异常')
break
f.close()
可以得到结果
G:\python>python test.py
46145 异常
打开这个文本文件,可以得到一个提示:
Collect the comments.
所以我们根据提示修改代码未下:
import re
import zipfile
#获得一个zipfile对象
f=zipfile.ZipFile('channel.zip','r')
name='90052'
file='.txt'
cinfo=[]
while name :
try:
a=f.read('%s'%(name+file))
#获取txt文件的zipinfo对象
b=f.getinfo(name+file)
#在cinfo列表中存储zipinfo对象的comment属性
cinfo.append(b.comment)
#a是一个bytes对象
name=re.findall(r'\d+',a.decode('utf-8'))[0]
#print(name)
except:
print (name,'异常')
break
f.close()
#cinfo列表中的为bytes对象,需要转换为str对象
print(''.join([i.decode('utf-8') for i in cinfo]))
————————————————————————————————————————————
最终:打印出来一个字符:
HOCKEY应该就是过关答案了。
赶紧把channel换成hockey,结果被告知去看一下使用的字母
原来答案就是拼图所用的字母序列,也就是,好吧,oxygen,这回没错了,
下一题的链接为:http://www.pythonchallenge.com/pc/def/oxygen.html