Invalid format character in string

Skip Montanaro skip at pobox.com
Fri Apr 4 17:43:18 EST 2003


    Nikolai> The problems arise where the HTML editor used (to produce the
    Nikolai> file in the first place) has put various expressions of %; and
    Nikolai> %>.  These are HTML codings the creator of the HTML file does
    Nikolai> not really know about.

Okay, how about a preprocessing step like this:

    data = open("htmlfile").read()
    # double up any % not followed by a left paren
    data = re.sub(r"%([^(])", r"%%\1", data)
    sys.stdout.write(data % valdict)

?  It's not perfect, but should be a lot better than the pain you're
experiencing now.

Skip





More information about the Python-list mailing list