'print' in a CGI app.

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Sun Aug 3 21:03:27 CEST 2003

Andrew Chalk wrote:

> In a Python 2.2 app. running under CGI the statements
> print "Hello\n"
> print "World"
> print both words on the same line in IE6. How do I print the second one on a
> new line (i.e. respect the \n in the first statement).

Umm. This has nothing to do with Python... but hey :-)
Unless your CGI script is set to content-type: text/plain,
you're supposed to print valid HTML.
You'll have more success if you print the following:

  print "<html><body>"		# begin HTML
  print "<pre>"			# HTML 'preformatted' block
  print "Hello\n"
  print "World"
  print "</pre>"			# end 'preformatted block'
  print "</body></html>"		# end HTML


More information about the Python-list mailing list