問題鏈接
問題鏈接如下:
http://www.pythonchallenge.com/pc/def/peak.html
答案鏈接
答案鏈接如下:
http://www.pythonchallenge.com/pc/def/channel.html
解題思路
根據(jù)頁面源碼提示:
<!-- peak hell sounds familiar ? -->
- python中發(fā)音類似的術語有picle。
源碼中還有如下信息:
<peakhell src="banner.p"/>
- 將URL替換,得到:
http://www.pythonchallenge.com/pc/def/banner.p,該頁面為picle數(shù)據(jù)。
使用代碼解碼后,仔細觀察可知,應當為由字符串組成的圖像,因此最終有如下代碼:
from urllib import request
from pickle import load
url = "http://www.pythonchallenge.com/pc/def/banner.p"
response = request.urlopen(url)
data = load(response)
for l in data:
m = ''
for t in l:
m += t[0]*t[1]
print(m)
輸出結(jié)果為:
##### #####
#### ####
#### ####
#### ####
#### ####
#### ####
#### ####
#### ####
### #### ### ### ##### ### ##### ### ### ####
### ## #### ####### ## ### #### ####### #### ####### ### ### ####
### ### ##### #### ### #### ##### #### ##### #### ### ### ####
### #### #### ### ### #### #### #### #### ### #### ####
### #### #### ### #### #### #### #### ### ### ####
#### #### #### ## ### #### #### #### #### #### ### ####
#### #### #### ########## #### #### #### #### ############## ####
#### #### #### ### #### #### #### #### #### #### ####
#### #### #### #### ### #### #### #### #### #### ####
### #### #### #### ### #### #### #### #### ### ####
### ## #### #### ### #### #### #### #### #### ### ## ####
### ## #### #### ########### #### #### #### #### ### ## ####
### ###### ##### ## #### ###### ########### ##### ### ######
- 仔細觀察應當為字符串
channel,替換URL中相關字符串得到最終的URL:http://www.pythonchallenge.com/pc/def/channel.html。