is it anyone got some idea why it happen?
cheng wrote:
>>>p.sub('','%s') % "a\nbc"
>>>
>>>
>'a\nbc'
>
>is it anyone got some idea why it happen?
>
Make that
p.sub('','%s' % "a\nbc")
Regards
/Mikael Olofsson
Universitetslektor (Senior Lecturer [BrE], Associate Professor [AmE])
Linköpings universitet
-----------------------------------------------------------------------
E-Mail: mik...@isy.liu.se
WWW: http://www.dtr.isy.liu.se/en/staff/mikael
Phone: +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
-----------------------------------------------------------------------
Linköpings kammarkör: www.kammarkoren.com Vi söker tenorer och basar!
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>
On Friday 27 May 2005 10:56 pm, cheng wrote:
> hi,all, i try to replace every target word found in the text
>
> for target in splitText:
> if stopwords.find(target) >= 0 :
> text = re.sub(r'\b%s\b','',text) &target
>
> when i using the statment:
>
> text = re.sub(r'\b%s\b','',text) &target
>
> get error : unsupported operand type(s) for &: 'str' and 'str'
>
> is it some idea that can modity it and make it work?
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095