Re: generate HTML



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@xxxxxxxxxxxxxxxxxx

.



Relevant Pages

  • Buffer Overflow with Python 2.5 on Vista in import site
    ... is working with and a string on encountering the bad path. ... snipped the first dump and only print the one with the traceback: ... [snip a load of null bytes] ... File "C:\Python25\lib\site.py", line 206, in addsitepackages ...
    (comp.lang.python)
  • Re: Entropy
    ... Thomas just thinks it's not very interesting to think about machine dependent KC. ... And as he said, if you look to eliminate the machine dependency, you marginalize it (you don't want to consider all machines, because then you have to look infinite time on infinite machines for a finite string, that's even worst). ...
    (comp.compression)
  • Re: RTF-Code und HTML
    ... > Hi Thomas ... > konvertieren...aber wie bekomme ich den string da rein? ... Du erstellst einen Bericht mit dem Textelement und stellst die ... Textinterpretation auf RTF: ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: CryptoStream
    ... > String mit 3DES verschlüsseln und wieder entschlüsseln, ... Gruß Thomas ... Prev by Date: ... Next by Date: ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • RE: Which is better?
    ... > You've lost me here Thomas. ... if you want to use the double quote character ... inside of such a string, you have to escape that character ...
    (perl.beginners)