Re: A simple question string.replace
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: A simple question string.replace

From: Emile van Sebille <emile@fenx.com>
Date: Tue Jan 31 2006 - 05:43:56 CET

"Haibao Tang" <tanghaibao@gmail.com> wrote in message
news:1138681387.207213.45940@g49g2000cwa.googlegroups.com...
>I have a two-column data file like this
> 1.1 2.3
> 2.2 11.1
> 4.3 1.1
> ...
> Is it possible to substitue all '1.1' to some value else without using
> re.
>

Yes --

data = """1.1 2.3
2.2 11.1
4.3 1.1"""

newdata = data.replace("1.1","1.x")

but that's probably not what you want.

Emile
Received on Tue Feb 7 20:18:57 2006