generate HTML
Thomas Guettler
niemand.leermann at thomas-guettler.de
Tue Nov 15 10:18:26 EST 2005
Am Tue, 15 Nov 2005 02:52:54 -0800 schrieb s99999999s2003:
> alist = [ '<div align="right"><font size="-1">....
> ValueError: unsupported format character '"' (0x22) at index 14
Look at this:
===> python
Python 2.3.4 (#1, Feb 7 2005, 15:50:45)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "a%qb%sc"
'a%qb%sc'
>>> "a%qb%sc" % (1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: unsupported format character 'q' (0x71) at index 2
If you don't have a '% (...)' behind the string, all percent signs are
ignored. But if you use it, %q will bring you an error because only %s, %d, ...
is supported.
If you create html, here the way I do it:
rows=[]
for i in range(...).
rows.append("....")
rows=''.join(rows)
date=time.strftime()
html="""
Today: %(date)s
<table>
%(rows)s
</table>
....""" % locals()
outfile="out.html"
fd=open(outfile, "wt")
fd.write(html)
fd.close()
print "Created %s" % outfile
HTH,
Thomas
--
Thomas Güttler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: niemand.leermann at thomas-guettler.de
More information about the Python-list
mailing list