Helpful Information
 
 
Category: Python Programming
embedded html causing problems

I'm writing a cgi with python at the minute and I seem to be getting some very strange errors from the embedded html.

I get ValueErrors for unsupported format character ' " ' at index 266

I have checked through my code and find myself unable to see what could be causing this error, as there are no ' " ' out of place.

If you can help I would greatly appreciate it.

Thanks

What do you mean with embedded HTML? You're using ASP+Python and <% + %> tags? Or are you just using the print statement?
Could you also post some code fro your script where you get your error?

Yeah sorry about that, I'm using %s and the html is actually within a cgi script as a variable, which can then be printed and the %s variables be defined.

Here's the html of the script:

<table bgcolor="#FFb573" width="65%" border="0" cellpadding="5" cellspacing="0">

<tr>
<td>mudid: </td>
<td>
<input type=text name=mudid>
</td>
</tr>
<tr>
<td>Server:<select "Server: " name="Server" align=left>
%s <!--Server list-->
</select></td>
<td>Database:<select name="Database" align=left>
%s <!--Database List-->
</select></td>
</tr>
<tr>
<td>search type: </td>
<td>substructure:
<input type=radio name=searchtype value=substrusture>
string:
<input type=radio name=searchtype value=string>
superstructure:
<input type=radio name=searchtype value=superstructure>
</td>
</tr>
<tr>
<td>smiles: </td>
<td>
<input type=text name=smi>
</td>
</tr>
<tr>
<td colspan=2><input type=hidden name=mol_inline><embed type="chemical/x-mdl-molfile" width=300 height=250 bgcolor=#ffffff queryformbox="document.qbuild.mol_inline">
</td>

</tr>
<tr>
<td>smiles or structure: </td>
<td>smiles:
<input type=radio value=strucorsmiles name=smiles>
structure:
<input type=radio value=strucorsmiles name=structure>
</td>
</tr>
</table>
</td></tr>
</table>

not really sure what could be causing the errors.
Thanks

I see the problem, you're using this code: 65%". Python thinks the % starts the format specifier, and then it reports " is an illegal format character. You should replace all % that are not used for formatting with %%.

http://python.sourceforge.net/devel-docs/lib/typesseq-strings.html










privacy (GDPR)