replacing characters within a string

Terry Reedy tjreedy at udel.edu
Sun Nov 9 12:08:02 EST 2008


Chris Rebert wrote:
> On Sat, Nov 8, 2008 at 9:16 PM, John Smith <swader at gmail.com> wrote:
>> Hi,
>>
>> I coded a python script that lets me parse a csv file into html code with a
>> certain format, but I would like to replace every "<" and ">" character that
>> appears within each column entry of the csv file (they are parsed as
>> strings) with the html equivalents of "<" and ">".

FYI: Python strings do have a .replace method,
but for the above application

> You want the cgi.escape() function -
> http://docs.python.org/library/cgi.html#cgi.escape

*is* what you should use, as it will do all needed replacements in one call.




More information about the Python-list mailing list