http://www.pythonchallenge.com/pc/def/ocr.htmlhtml
recognize the characters. maybe they are in the book,
but MAYBE they are in the page source.python
打开页面源代码,能够看到下面的信息:正则表达式
<!-- find rare characters in the mess below: -->
经过给出的提示“find rare characters in the mess below”,咱们能够知道线索就在第二个<!-- -->中,不失通常性,设计python代码以下:url
import re import urllib import string # 使用urllib模块读取页面源代码 sock = urllib.urlopen("http://www.pythonchallenge.com/pc/def/ocr.html") source = sock.read() sock.close() # 标志re.S表示在正则表达式中点(.)能够匹配任意字符,包括换行符 data = re.findall(r'<!--(.+?)-->', source, re.S) charList = re.findall(r'([a-zA-Z])', data[1], 16) # 使用string模块将list转为字符串打印 print string.join(charList)
输出:spa
“e q u a l i t y”设计
下一关:http://www.pythonchallenge.com/pc/def/equality.htmlcode