2006年05月01日 星期一 12:53
应该是li.search(str).group() 或 li.search(str).groups() 吧 On 4/30/06, biosedit at gmail.com <biosedit at gmail.com> wrote: > > |#!/usr/bin/python > 3 |# This Python file uses the following encoding: utf-8 > 4 |import re > 5 |pattern='^[^1]' > 6 |f=open('/var/log/apache2/access.log','r') > 7 |readlines=f.readlines() > 8 |for str in readlines: > 9 | li =re.compile(pattern) > 10 | li.search(pattern).groups() > 11 |f.close() > | > File "./http.py", line 9 > li.search(pattern).groups() > ^ > IndentationError: unindent does not match any outer indentation level > > http://www.woodpecker.org.cn/obp/diveintopython-zh-5.4/zh-cn/dist/html/toc/index.html > groups()该怎么用 > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060501/0a36029c/attachment.html
2006年05月01日 星期一 16:15
用re.findall()方法……返回一个数组……包含所有符合匹配条件的字符串…… 在06-5-1,Gu Yingbo <tensiongyb at gmail.com> 写道: > > 应该是li.search(str).group() 或 li.search(str).groups() 吧 > > On 4/30/06, biosedit at gmail.com < biosedit at gmail.com> wrote: > > > |#!/usr/bin/python > 3 |# This Python file uses the following encoding: utf-8 > 4 |import re > 5 |pattern='^[^1]' > 6 |f=open('/var/log/apache2/access.log','r') > 7 |readlines=f.readlines() > 8 |for str in readlines: > 9 | li =re.compile(pattern) > 10 | li.search(pattern).groups() > 11 |f.close() > | > File "./http.py", line 9 > li.search(pattern).groups() > ^ > IndentationError: unindent does not match any outer indentation level > > http://www.woodpecker.org.cn/obp/diveintopython-zh-5.4/zh-cn/dist/html/toc/index.html > groups()该怎么用 > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060501/98966daf/attachment.htm
Zeuux © 2025
京ICP备05028076号