Python论坛  - 讨论区

标题:Re: [python-chinese] 怎样截取字段

2006年05月01日 星期一 12:53

Gu Yingbo tensiongyb at gmail.com
Mon May 1 12:53:27 HKT 2006

应该是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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年05月01日 星期一 16:15

骨头 ymirsoft at gmail.com
Mon May 1 16:15:02 HKT 2006

用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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号