String Handling
Wm. King
wjk at wjk.mv.com
Tue Jan 4 18:48:09 EST 2000
As an alternative from a newbie:
import re
replacement = re.compile(" ")
str1 = "Lucy by the carriage"
str2 = replacement.sub("+",str1)
.... should result in str2 as 'Lucy+by+the+carriage'
though I would opt for import string and string.replace()
Simon Faulkner wrote:
> Hi All,
>
> Can anyone give me the Python line/command to change all spaces in a
> string to +s?
>
> ie
>
> "Lucy by Railway Carraige"
>
> becomes
>
> "Lucy+by+Railway+Carraige"
>
> Muchos gratcias etc
>
> Simon
> Simon Faulkner
More information about the Python-list
mailing list