Well I'm going to assume you have everything necessary set up... such as the web server, CGI support, placed the script in the appropriate directory, linked the .py extention to the cgi-handler, etc...
Then, your code should start off with something like:
#!c:/python24/python
import cgitb
import cgi
cgitb.enable()
print "Content-type: text/html\r"
print "\r"
Depending on your CRLF, and location of Python. My example is if the web server is on Windows, with the Python interpreter at
c:/python24/python.exe.