python challenge 6解题总结

python challenge 6的网址:www.pythonchallenge.com/pc/def/channel.html

这一关只有这一张图片,并且从源码里面也没有得出什么具体的信息,于是突然想到zip可以表示图片里面的拉链的意思,于是打开www.pythonchallenge.com/pc/def/channel.zip, 原来玄机就在这里。对付ZIP,python模块里面有zipfile

解题代码如下:

import zipfile, re
start = '90052'
r = 'Next nothing is (d+)'
file = zipfile.ZipFile('D:channel.zip')
f = "%s.txt"
c = []
while True:
      try:
          start = re.search(r, file.read(f % start)).group(1)
     except:
         print file.read(f % start)
         break
     c.append(file.getinfo(f % start).comment)
print "".join(c)