PythonChallenge之level-6解题报告

PythonChallenge之level-6解题报告

前面有几个还没写 下次有时间了补上

level-6:
题目地址:
http://www.pythonchallenge.com/pc/def/channel.html

啥都没有?

在这种情况下 咱们一般都是去看源代码



PythonChallenge之level-6解题报告_第1张图片


有个zip提示 ,那么咱们把html改成http://www.pythonchallenge.com/pc/def/channel.zip

可以下载,下载下来发现是一个zip包

看到一个readme.txt

提示如下:


PythonChallenge之level-6解题报告_第2张图片


看了下txt,发现跟前面的一关很像,于是这样写代码:

nothing='90052'
while 1:
    if not nothing:
        break
    else:
        file=open('./channel/%s.txt' % nothing,'r')
        s=file.read()
        print(s)
        index=s.index('is')+3
        nothing=s[index:]
        print(nothing)

发现 程序在46145处停止了

PythonChallenge之level-6解题报告_第3张图片

打开这个文件 看到:
PythonChallenge之level-6解题报告_第4张图片

到这个就不知道咋办
幸好 我有一个大神舍友 在他的提示下,去百度了下 zipfile这个模块

没错 ,这关需要用到zipfile!!!

具体怎么用自己去百度吧 我上代码:

nothing='90052.txt'
z=zipfile.ZipFile('channel.zip')
while 1:
    content=z.read(nothing)
    sys.stdout.write(z.getinfo(nothing).comment)
    if 'comments' in content:
        break
    index=content.index('is')+3
    nothing=content[index:]+'.txt'

程序运行结果:

PythonChallenge之level-6解题报告_第5张图片

到这里 好激动 赶紧提交

PythonChallenge之level-6解题报告_第6张图片

没想到出来一句话 说什么在空气中,什么鬼…………

苦思冥想,找不到答案,回头去看HOCKEY

哟 让我发现了答案 原来就是组成HOCKEY 的那些字母啊

oxygen(氧气)

终于,答案正确

通关地址:

http://www.pythonchallenge.com/pc/def/oxygen.html

接下来进入下一关

你可能感兴趣的:(PythonChallenge之level-6解题报告)