learning python, using string help

mikeisgreat at gmail.com mikeisgreat at gmail.com
Thu Feb 2 19:13:42 EST 2006


thanks tom,

I am running OpenBSD, NetBSD as well as OS X (FreeBSD)

My first python script

#!/usr/local/bin/python

print "Content-type:text/html\n\n";

import os, string

getrup = os.popen('ruptime').read()
show = getrup.splitlines()

for line in show:
	if line.find("up" or "down"):
		UP = "<font color='GREEN'>UP</font>"
		DOWN = "<font color='RED'>DOWN</font>"
		line = line.replace("up", UP )
		line = line.replace("down", DOWN )

		print "<pre>%s</pre>" % line

But I was refering to more or lest format specifiers like  %2d, %2s,
%.2f
I know I can do it in HTML or CSS.

But I am glad you sent me that code ... it has helped me learn.

--thanks




More information about the Python-list mailing list