learning python, using string help

Paul McGuire ptmcg at austin.rr._bogus_.com
Thu Feb 2 13:50:51 EST 2006


<mikeisgreat at gmail.com> wrote in message
news:1138906062.727850.177960 at g14g2000cwa.googlegroups.com...
> hi all,
>
> I have a simple snippet I am trying to keep the format the same as
> plain text, though I want to embed it in html ...
>
> basically,
>
> print "Content-type:text/plain\n\n";
> getrup = os.popen('ruptime').read()
> print getrup
>
> is the same format as if I ran 'ruptime' from the command line.
>
> If I use...
>
> print "Content-type:text/html\n\n";
> getrup = os.popen('ruptime').read()
> print getrup
>
> I can just split the lines and loop through it ... but I am not sure
> how to keep the tab spacing the same
> I'm sure its something so simple I am missing ....
>
> thanks for helping someone learning..
> --mike
>
What about :

print "Content-type:text/html\n\n";
print "<pre>"
getrup = os.popen('ruptime').read()
print getrup
print "</pre>"

The <pre> tags indicate that the enclosed text has been pre-formatted.
Otherwise your tabs will get collapsed out by HTML.

-- Paul





More information about the Python-list mailing list