[mod_python] unsupported format character '"' (0x22) at index 30

Robert Brewer fumanchu at amor.org
Wed Dec 15 10:43:15 EST 2004


Lee jundong wrote:
> I find a matter.In case of using "%" symbol to link string,like:print
> str1%str2.It can't work  with Modpython.But it can work ok with pure
> python.How to do it?

The width values in your HTML have % characters. These need to be
escaped when using string formatting:
http://docs.python.org/lib/typesseq-strings.html

The quickest way to get yours to work is to simply double every
extraneous % in your content:

--------------welcome.py------------------
def welcome (req):
    content = """
<table border="0" width="100%%">
  <tr>
    <td width="15%%" valign="top">%s<!--Menu-->
    </td>
    <td width="85%%" valign="top">WELCOME!</td>
  </tr>
</table>
"""
    return content % frame.Menu()


Robert Brewer
MIS
Amor Ministris
fumanchu at amor.org



More information about the Mod_python mailing list