打开第六关,看到了一个拉链图片,联想到zip,打开源代码第一行果然有注释内容zip
于是把网页地址替换为http://www.pythonchallenge.com/pc/def/zip.html,然后就可以看到如下提示:
yes. find the zip.
原来是要找一个压缩文件啊,窝不断地尝试终于发现http://www.pythonchallenge.com/pc/def/channel.zip是下载地址
下载后打开channel.zip压缩文件,查看readme.txt,发现:
welcome to my zipped list. hint1: start from 90052 hint2: answer is inside the zip
原来是像之前网址链接一样遍历,只不过这次迭代对象变成了文件,提示告诉我们从90052开始,答案在zip文件里(有深意。。。)
将文件解压,然后遍历:
import os
path1=os.path.abspath('.')+"\channel\\"
init=str(90052);
while 1:
file1=file(path1+init+".txt").read()
print file1
init=file1.split(' ')[-1]
得到结果:
Collect the comments.不明觉厉啊,求助度娘后发现zip文件有comment属性,原来题目是要我们把comment收集起来,于是乎:
import zipfile
value=90052
comments=[]
z =zipfile.ZipFile("channel.zip")
while True:
try:
content=z.read('%s.txt'%value)
print z.getinfo('%s.txt'%value).comment
comments.append(z.getinfo('%s.txt'%value).comment)
value=content.split(' ')[-1]
print content
except Exception,e:
print e
break
print ''.join(comments)
发现打印输出:
于是把网址替换为http://www.pythonchallenge.com/pc/def/hockey.html,告诉我们要look at the letters
原来网址是组成哪些字母图片的字母本身。。。
将网址替换为http://www.pythonchallenge.com/pc/def/oxygen.html成功进入下一关!