Invalid format character in string

Nikolai Kirsebom nikolai.NOJUNK at
Sun Apr 6 00:00:11 CEST 2003

On Fri, 4 Apr 2003 16:43:18 -0600, Skip Montanaro <skip at>

>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.

Thanks for all the answers.

I think I'll go for the Skip Montanro's suggestion
(double up any % not followed by a left parenthesis). 


More information about the Python-list mailing list