PythonChallenge Level 6

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

做完这一题给我的感觉是:好爽!

这一题好曲折啊。首先,看page source,第一行的提示很隐蔽啊:<!-- <-- zip -->。提示我们将html改成zip ,得到一个.zip文件。看到里面的内容都是类似“Next nothing is 83831”,于是看83831.txt又提示“Next nothing is 80100”,和第5关类似。于是果断代码:

import re head_file = '/tmp/channel/' end_file = '.txt' nothing = '90052' pattern = re.compile( ' (/d*)$' ) intent = '' while True: intent = open( head_file + nothing + end_file , 'r' ).read() m = re.findall( pattern , intent ) if bool( m ): nothing = m[ 0 ] else: break print intent

结果:Collect the comments.

怎么,又要找相应文件的comment啊?OK:

import zipfile import urllib import re comments = [] nothing = '90052' end_str = '.txt' pattern = re.compile( ' (/d*)$' ) url = 'http://www.pythonchallenge.com/pc/def/channel.zip' zip = zipfile.ZipFile( urllib.urlretrieve( url )[ 0 ] , 'r' ) while True: try: comments.append( zip.getinfo( nothing + end_str ).comment ) nothing = re.findall( pattern , zip.read( nothing + end_str ) )[ 0 ] except: break print ''.join( comments )

 

结果:又是一幅图,好,我就喜欢图!

**************************************************************** **************************************************************** ** ** ** OO OO XX YYYY GG GG EEEEEE NN NN ** ** OO OO XXXXXX YYYYYY GG GG EEEEEE NN NN ** ** OO OO XXX XXX YYY YY GG GG EE NN NN ** ** OOOOOOOO XX XX YY GGG EEEEE NNNN ** ** OOOOOOOO XX XX YY GGG EEEEE NN ** ** OO OO XXX XXX YYY YY GG GG EE NN ** ** OO OO XXXXXX YYYYYY GG GG EEEEEE NN ** ** OO OO XX YYYY GG GG EEEEEE NN ** ** ** **************************************************************** **************************************************************
可以清楚的看到是单词:hockey。于是高兴的改成hockey。谁知又提示:it's in the air. look at the letters.

再看一下结果,知道了怎么回事了。

答案:oxygen

 

你可能感兴趣的:(PythonChallenge Level 6)