Python论坛  - 讨论区

标题:[python-chinese] 大家帮忙看一下,re的问题

2005年12月05日 星期一 14:21

HoLin holin.he at gmail.com
Mon Dec 5 14:21:40 HKT 2005

代码
import re
s = 'Begin ' + 1000*'a very long string ' + 'end'
re.match('Begin (\w| )*? end', s).end()

出错提示
Traceback (most recent call last):
  File "re.py", line 1, in ?
    import re
  File "E:\My Documents\work\PythonTest\re.py", line 3, in ?
    re.match('Begin (\w| )*? end', s).end()
AttributeError: 'module' object has no attribute 'match'

re是自带的吧?怎么会不行呢?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051205/85f87b10/attachment.html

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

2005年12月05日 星期一 14:43

HoLin holin.he at gmail.com
Mon Dec 5 14:43:08 HKT 2005

import regex as re

原来还是regex,但是运行的时候提示用re,regex已经deprecated。
这怎么回事啊,我用的是python2.4.1



在05-12-5,HoLin <holin.he at gmail.com> 写道:
>
> 代码
> import re
> s = 'Begin ' + 1000*'a very long string ' + 'end'
> re.match('Begin (\w| )*? end', s).end()
>
> 出错提示
> Traceback (most recent call last):
>   File "re.py", line 1, in ?
>     import re
>   File "E:\My Documents\work\PythonTest\re.py", line 3, in ?
>     re.match('Begin (\w| )*? end', s).end()
> AttributeError: 'module' object has no attribute 'match'
>
> re是自带的吧?怎么会不行呢?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051205/87f484b0/attachment.htm

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

2005年12月05日 星期一 14:56

Scorpio Auding auding at gmail.com
Mon Dec 5 14:56:54 HKT 2005

*Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] 
on win32
*
运行结果:_*19008*_

-- 
CopyLeft (C) Scorpio Auding

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051205/4cea4135/attachment.html

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

2005年12月05日 星期一 15:06

Bruce Wang number5 at gmail.com
Mon Dec 5 15:06:19 HKT 2005

On 12/5/05, HoLin <holin.he at gmail.com> wrote:
>
> 代码
> import re
> s = 'Begin ' + 1000*'a very long string ' + 'end'
> re.match('Begin (\w| )*? end', s).end()
>
> 出错提示
> Traceback (most recent call last):
>   File "re.py", line 1, in ?
>     import re
>   File "E:\My Documents\work\PythonTest\re.py", line 3, in ?
>     re.match('Begin (\w| )*? end', s).end()
> AttributeError: 'module' object has no attribute 'match'
>
> re是自带的吧?怎么会不行呢?
>
>
试试改文件名 re.py 改成 其他 比如 testRE.py


--
simple is good
http://datastrategy.org/number5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20051205/c6f7dc8e/attachment.htm

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

2005年12月05日 星期一 15:10

kebo wang kebowang at gmail.com
Mon Dec 5 15:10:47 HKT 2005

On 12/5/05, Scorpio Auding <auding at gmail.com> wrote:
> Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
> win32
>
> 运行结果:19008

ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on
Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> s = 'Begin ' + 1000*'a very long string ' + 'end'
>>> re.match('Begin (\w| )*? end', s).end()
19009

--
Best Regards,
mep

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

2005年12月05日 星期一 15:11

徐可 netmud at gmail.com
Mon Dec 5 15:11:20 HKT 2005

我曾把文件名叫做 socket.py ,结果 ...

On 12/5/05, Bruce Wang <number5 at gmail.com> wrote:
>
> On 12/5/05, HoLin <holin.he at gmail.com> wrote:
> >
> > 代码
> > import re
> > s = 'Begin ' + 1000*'a very long string ' + 'end'
> > re.match('Begin (\w| )*? end', s).end()
> >
> > 出错提示
> > Traceback (most recent call last):
> >   File "re.py", line 1, in ?
> >     import re
> >   File "E:\My Documents\work\PythonTest\re.py", line 3, in ?
> >     re.match('Begin (\w| )*? end', s).end()
> > AttributeError: 'module' object has no attribute 'match'
> >
> > re是自带的吧?怎么会不行呢?
> >
> >
> 试试改文件名 re.py 改成 其他 比如 testRE.py
>
>
> --
> simple is good
> http://datastrategy.org/number5
> _______________________________________________
> 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/20051205/348f0a7b/attachment.html

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

2005年12月05日 星期一 15:15

HoLin holin.he at gmail.com
Mon Dec 5 15:15:21 HKT 2005

哈哈,真强,就是把文件取名为re了。
不过又没找到findall函数 =_=#


在05-12-5,Bruce Wang <number5 at gmail.com> 写道:
>
> On 12/5/05, HoLin <holin.he at gmail.com> wrote:
> >
> > 代码
> > import re
> > s = 'Begin ' + 1000*'a very long string ' + 'end'
> > re.match('Begin (\w| )*? end', s).end()
> >
> > 出错提示
> > Traceback (most recent call last):
> >   File "re.py", line 1, in ?
> >     import re
> >   File "E:\My Documents\work\PythonTest\re.py", line 3, in ?
> >     re.match('Begin (\w| )*? end', s).end()
> > AttributeError: 'module' object has no attribute 'match'
> >
> > re是自带的吧?怎么会不行呢?
> >
> >
> 试试改文件名 re.py 改成 其他 比如 testRE.py
>
>
> --
> simple is good
> http://datastrategy.org/number5
> _______________________________________________
> 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/20051205/0f7f8a0e/attachment.htm

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

2005年12月05日 星期一 17:14

amingsc amingsc at 163.com
Mon Dec 5 17:14:07 HKT 2005

在 2005年12月5日 星期一 15:15,HoLin 写道:
> 哈哈,真强,就是把文件取名为re了。
> 不过又没找到findall函数 =_=#
>
>
> 在05-12-5,Bruce Wang <number5 at gmail.com> 写道:
>
> > On 12/5/05, HoLin <holin.he at gmail.com> wrote:
> > > 代码
> > > import re
> > > s = 'Begin ' + 1000*'a very long string ' + 'end'
> > > re.match('Begin (\w| )*? end', s).end()
> > >
> > > 出错提示
> > > Traceback (most recent call last):
> > >   File "re.py", line 1, in ?
> > >     import re
> > >   File "E:\My Documents\work\PythonTest\re.py", line 3, in ?
搞不懂,python安装的re文件怎么在这个目录下?
E:\My Documents\work\PythonTest\re.py
去文档看看import搜索路径的顺序不就成了嘛

> > >     re.match('Begin (\w| )*? end', s).end()
> > > AttributeError: 'module' object has no attribute 'match'
> > >
> > > re是自带的吧?怎么会不行呢?
> >
> > 试试改文件名 re.py 改成 其他 比如 testRE.py
> >
> >
> > --
> > simple is good
> > http://datastrategy.org/number5
> > _______________________________________________
> > 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

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号