跳至内容
Python 俱乐部
用户工具
登录
站点工具
搜索
工具
显示页面
修订记录
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您的足迹:
python-hacks:re-find
====== 得到正则表达式中特定单元内容 ====== 下面的例子是用Python得到网页的标题 ===== 代码 ===== <code python> import urllib import re f = urllib.urlopen("http://www.google.com/") raw_html = f.read() patt = """<title>([^<]*)</title>""" all = re.findall(patt, raw_html, re.IGNORECASE) title = "".join(all) print title </code> ===== 技巧 ===== 使用 join 方法可以将得到的列表转为字符串
python-hacks/re-find.txt
· 最后更改: 2010/06/02 01:18 (外部编辑)
页面工具
显示页面
修订记录
反向链接
回到顶部