Python Challenge Level 5

Level 5:

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

这一关比较有意思,打开page source code,提示信息为<!-- peak hell sounds familiar ? -->,打开peakhell标签,发现banner.p为一系列无意义的字符集。peakhell谐音为pickle,可知需要从序列化入手。

#!/usr/bin/python  
  
import urllib.request  
import pickle
""" 
Python Challenge, Level 5: 
    http://www.pythonchallenge.com/pc/def/peak.html
"""  

def banner(url):
    try:
        with urllib.request.urlopen(url) as resp:
            entry = pickle.load(resp)    # get a two-dimensional array for drawing the banner
            for line in entry :
                print(''.join(map(lambda x: x[0]* x[1], line)))
    except Exception as ex : 
        print(ex)
def main():  
    url = 'http://www.pythonchallenge.com/pc/def/banner.p'
    banner(url)
    
if __name__ == '__main__':  
  main()  

 在终端打印结果为:channel

替换url,进入下一关:http://www.pythonchallenge.com/pc/def/channel.html

 

 

你可能感兴趣的:(python)