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

recognize the characters. maybe they are in the book, 
but MAYBE they are in the page source.

打开页面源代码,可以看到下面的信息:

<!--
find rare characters in the mess below:
-->

通过给出的提示“find rare characters in the mess below”,我们可以知道线索就在第二个<!-- -->中,不失一般性,设计python代码如下:

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)

输出:

“e q u a l i t y”

下一关:http://www.pythonchallenge.com/pc/def/equality.html

urllib模块

python challenge - orc.py的更多相关文章

  1. python challenge - map.py

    Hint: K->M    O->Q    E->G everybody thinks twice before solving this. g fmnc wms bgblr rpy ...

  2. python下编译py成pyc和pyo

     python下编译py成pyc和pyo   其实很简单, 用 python -m py_compile file.py python -m py_compile /root/src/{file1,f ...

  3. python 装 ez_setup.py 出错

    python 装 ez_setup.py出错setuptools,pip,install,UnicodeDecodeError: 'ascii' codec can't decode byte.解决: ...

  4. python challenge第1关--NoteBook上的“乱码”

    在 python challenge第0关中已经得到第1关的地址了: http://www.pythonchallenge.com/pc/def/map.html 一.观察地址栏和标签: What a ...

  5. python中__init__.py文件的作用

    问题 在执行models.py时,报ImportError:No module named transwarp.db的错误,但明明transwarp下就有db.py文件,路径也没有错误.真是想不通.后 ...

  6. Python Challenge 过关心得(0)

    最近开始用Openerp进行开发,在python语言本身上并没有什么太大的进展,于是决定利用空闲时间做一点python练习. 最终找到了这款叫做Python Challenge(http://www. ...

  7. Python Challenge 第四题

    这一题没有显示提示语,仅仅有一幅图片,图片也看不出什么名堂,于是直接查看源代码,源代码例如以下: <html> <head> <title>follow the c ...

  8. Python的__init__.py用法

    python中包的引入,对于大型项目中都会使用到这个功能,把实现不同功能的python文件放在一起,组成不同lib库,然后在其他地方调用. 包,python源文件+__init__.py 模块,pyt ...

  9. python d:\test.py File "<stdin>", line 1 python d:\test.py ^ SyntaxError: invalid syntax

    pyhton出错: python d:\test.py File "<stdin>", line 1 python d:\test.py ^SyntaxError: i ...

随机推荐

  1. 记录一次WebService使用的经历

    于业务需要,需要和第三方对接一些接口,但是问题是,他们的接口提供是webservice的,本人只精通restful接口(也就是说我比较年轻^-^).好在对面人特别奈斯,一顿指导我,感谢. 废话不多说了 ...

  2. linux下redis的最佳实践(Master-Slave)

    本文演示了redis在同一台linux上的安装及运行多个实例,并演示了主从复制,以及如何进行主从的切换. 1. 下载 $ wget http://download.redis.io/releases/ ...

  3. Aras增加新用户

    Aras中新增用户,这里特别提醒,用户密码下面的可以登陆必须勾选,如不勾选刚出现不能登陆的情况. 增加用户后,将用户加入至与原同事一样的Identities(例如Sales/All Employees ...

  4. F - Oil Deposits 【地图型BFS+联通性】

    The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSu ...

  5. HDU 多校1.5

    Expectation Division Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/O ...

  6. Python3 list记录

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author;Tsukasa name = ['YangJiaHui','LiuYueEr','TaB ...

  7. hdu6121

    hdu6121 题意 给出一棵树,\(0\) 为根节点,节点 \(i\) 的父节点标号是 \(\lfloor\frac{i-1}{k}\rfloor\),求所有子树大小的异或和. 分析 找规律.在纸上 ...

  8. 洛谷——P1604 B进制星球

    P1604 B进制星球 题目背景 进制题目,而且还是个计算器~~ 题目描述 话说有一天,小Z乘坐宇宙飞船,飞到一个美丽的星球.因为历史的原因,科技在这个美丽的星球上并不很发达,星球上人们普遍采用B(2 ...

  9. 【莫队算法】bzoj3289 Mato的文件管理

    莫队算法,离线回答询问,按一定大小(sqrt(n*log(n))左右)将答案分块,按 ①左端点所在块②右端点 双关键字排序. 然后暴力转移. 转移的时候用树状数组. O(n*sqrt(n)*log(n ...

  10. 修改 CentOS 6.3 时区 和 时间

    1.查看当前时区和时间 date -R 2.CentOS中时区是以文件形式存在,当前时区文件位于 /etc/localtime 其他时区文件位于 /usr/share/zoneinfo下,其中中国时区 ...