Invalid format character in string

Nikolai Kirsebom nikolai.NOJUNK at micon.no
Fri Apr 4 17:17:52 EST 2003


Hi,
The problems arise where the HTML editor used (to produce the file in
the first place) has put various expressions of %; and %>.  These are
HTML codings the creator of the HTML file does not really know about.
As an example, I've just told them (the users creating the HTML file)
that they should write the text "%(name)s" where they want the name
generated and "%(age)s" where they want the age generated.  Then my
script is run for a set of person objects producing a set of HTML
files with the correct names and corresponding ages. 

On Fri, 4 Apr 2003 15:59:48 -0600, Skip Montanaro <skip at pobox.com>
wrote:

>
>    Nikolai> ... since the text is actually a HTML file, it may contain a
>    Nikolai> lot of characters with % (typically cell width definitions of
>    Nikolai> tables).  If these are contained in the file, the string format
>    Nikolai> statement complains about illegal format character.  
>
>Just double any literal % characters, e.g.:
>
>    <table width="%(width)s%%">
>
>Skip





More information about the Python-list mailing list