[Tutor] Passing data from html to py
jfouhy at paradise.net.nz
jfouhy at paradise.net.nz
Thu Mar 24 01:55:34 CET 2005
Quoting Vicki Stanfield <vicki at stanfield.net>:
> > for key in form:
> > print '%s: %s' % (key, form[key].value)
> Thanks John,
> That is exactly what I was looking for. I would like to add a newline
> after each line. I tried adding a \n after the second %s, but that
> doesn't seem to work. But wait, it works interactively. Any idea why it might
> not work in this script.
>
> for key in form:
> print '%s: %s/n/n' % (key, form[key].value)
Hi Vicki ---
Two things:
Firstly, a there is a difference between /n and \n :-)
Secondly, remember that all whitespace (including newlines) in HTML is collapsed
down to a single space.
The newlines will be there, but your web browser is just ignoring them. A quick
fix is something like '%s: %s<br>' % (key, form[key].value).
--
John.
More information about the Tutor
mailing list