读书人

python 正则表达式运用笔记

发布时间: 2012-12-26 14:39:29 作者: rapoo

python 正则表达式使用笔记

import os,urllib,urllib2import re,sysurl = "http://www.iteye.com"page = urllib.urlopen(url).read()str = re.compile('<script([\S\s]*?)<\/script>')b = str.sub('',page)str = re.compile('<.*?>')b = str.sub('',b)wordlist = re.findall('[a-zA-Z]{3,}',b)for aword in wordlist:    print aword

读书人网 >perl python

热点推荐