http://www.cnblogs.com/agateriver/archive/2005/08/29/225565.html Agate River's Home Focus on Python, QT, XeTeX and others. 首页 新随笔 联系 聚合 管理 posts - 12, comments - 4, trackbacks - 0 Python正则表达式的用法(2. 替换;3.拆分) 字符串替换 1.替换所有匹配的子串 1 #用newstring替换subject中所有与正则表达式regex匹配的子串 2 result = re. sub (regex, newstring, subject) 2.替换所有匹配的子串(使用正则表达式对象) 1 reobj = re.compile(regex) 2 result = reobj. sub (newstring, subject) 字符串拆分1.字符串拆分 1 result = re. split (regex, subject) 2.字符串拆分(使用正则表示式对象) 1 reobj = re.compile(regex) 2 result = reobj. split (subject) posted on 2005-08-29 20:27 玛瑙河 阅读(223) 评论(0) 编辑 收藏 引用 网摘 所属分类: Python 刷新评论列表 <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> width="468" scrolling="no" height="60" frameborder="0" allowtransparency="true" hspace="0" vspace="0" marginheight="0" marginwidth="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4210569241504288&dt=1182916519359&lmt=1182916518&format=468x60_as&output=html&correlator=1182916519359&url=http%3A%2F%2Fwww.cnblogs.com%2Fagateriver%2Farchive%2F2005%2F08%2F29%2F225565.html&color_link=6699CC&ad_type=text&ref=http%3A%2F%2Fwww.cnblogs.com%2Fagateriver%2Fcategory%2F68961.html&cc=71&flash=9&u_h=1024&u_w=1280&u_ah=957&u_aw=1280&u_cd=32&u_tz=480&u_his=4&u_java=true&u_nplug=30&u_nmime=151" name="google_ads_frame"> 标题请输入标题姓名请输入你的姓名主页 请输入验证码 验证码* 内容(请不要发表任何与政治相关的内容) 请输入评论内容 Remember Me? 登录 使用高级评论 新用户注册 返回页首 恢复上次提交 [使用Ctrl+Enter键可以直接提交] 相关文章: 用Python编写自动下载网络小说的脚本 Python & ADO Python正则表达式的用法(2. 替换;3.拆分) Python正则表达式的用法(1. 匹配) width="468" scrolling="no" height="80" frameborder="0" allowtransparency="true" style="border: 0px solid rgb(102, 102, 102);" src="http://www.cnblogs.com/ad.htm" marginwidth="0" marginheight="0"> 常用链接 我的随笔我的评论我参与的随笔 留言簿(1) 给我留言 查看公开留言 查看私人留言 随笔分类 Python(4) XeTeX(3) 旅途(1) 闲看三国 杂记(3) 随笔档案 2007年4月 (3) 2006年9月 (1) 2006年4月 (2) 2006年2月 (1) 2005年9月 (1) 2005年8月 (4) 相册 鄙人 虎跳峡 丽江 香格里拉—梅里 友情链接 limodou的blog 博客园电子期刊 最新随笔 1. 中文首行缩进的设置2. 使verbatim环境在XeTeX下支持中文3. XeTeX下制作beamer演示文稿初体验4. 用Python编写自动下载网络小说的脚本5. Python & ADO6. I Belive I Can Fly Lyrics7. 幸福在哪里8. 心的独旅9. About my photo!10. Python正则表达式的用法(2. 替换;3.拆分) 搜索 最新评论 1. re: 开张志喜! 白洋 --玛瑙河 2. re: 开张志喜! 恭喜! 安福寺人? --田勇志 3. re: 开张志喜! 感谢光临!老家枝江! --玛瑙河 4. re: 开张志喜! 评论内容较长,点击标题查看 --syrinx