A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/328986.html below:

Replacing large number of substrings

Replacing large number of substrings Replacing large number of substringsWill McGugan news at NOwillmcguganSPAM.com
Sun Sep 4 09:41:00 EDT 2005
Hi,

Is there a simple way of replacing a large number of substrings in a 
string? I was hoping that str.replace could take a dictionary and use it 
to replace the occurrences of the keys with the dict values, but that 
doesnt seem to be the case.

To clarify, something along these lines..

 >>> dict_replace( "a b c", dict(a="x", b="y") )
"x y c"


Regards,

Will McGugan
--
http://www.kelpiesoft.com

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4