a re problem
Fredrik Lundh
fredrik at pythonware.com
Fri May 20 10:21:43 EDT 2005
"cheng" <magicmas at spymac.com> wrote:
> >>> p.sub('','a\nbc')
> 'abc'
> >>> p.sub('','%s') % "a\nbc"
> 'a\nbc'
>
> is it anyone got some idea why it happen?
>>> p.sub('', 'a\nbc')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'p' is not defined
>>> import re
>>> p = re.compile("\n*")
>>> p.sub("", "a\nbc")
'abc'
>>> p.sub("", "%s")
'%s'
</F>
More information about the Python-list
mailing list