Invalid format character in string

Nikolai Kirsebom nikolai.NOJUNK at micon.no
Fri Apr 4 16:50:47 EST 2003


I have a file (HTML) containing a set of %(name)s entries.  When I run
a string format statement of the content of the file towards a
dictionary object, the values for the corresponding keys are replaced
correctly.  However, since the text is actually a HTML file, it may
contain a lot of characters with % (typically cell width definitions
of tables).  If these are contained in the file, the string format
statement complains about illegal format character.  I've
(temporarily) solved it by replacing the sequences '%;' and '%>' with
something else and then restore the sequences after the string format
statement.  It works, but I'm sure there is a more elegant (and not
hard-coded) solution.

Any help is appreciated.
Nikolai Kirsebom





More information about the Python-list mailing list