<p>你问的是所谓的CGI。Python为它提供了一个模块:<br/>
<a href="http://docs.python.org/library/cgi.html" rel="nofollow">http://docs.python.org/library/cgi.html</a></p>
<p>但是CGI现在有点过时了,因为它通常是为python应用程序提供服务的非常低效的方法。最好使用某种类型的<a href="http://wiki.python.org/moin/WebFrameworks/" rel="nofollow">python web framework</a>。</p>
<p><a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface" rel="nofollow">Common Gateway Interface</a></p>
<blockquote>
<p>A web server that supports CGI can be configured to interpret a URL
that it serves as a reference to a CGI script. A common convention is
to have a cgi-bin/ directory at the base of the directory tree and
treat all executable files within it as CGI scripts. Another popular
convention is to use filename extensions; for instance, if CGI scripts
are consistently given the extension .cgi, the web server can be
configured to interpret all such files as CGI scripts.<br/>
In the case of
HTTP PUT or POSTs, the user-submitted data is provided to the program
via the standard input. The web server creates a small and efficient
subset of the environment variables passed to it and adds details
pertinent to the execution of the program.</p>
</blockquote>
<p>这如何适用于您的问题是,您的<code>script.py</code>需要首先位于<code>cgi-bin</code>或web服务器配置为识别该类型的类似位置中。其次,您需要使用<code>cgi</code>python模块来访问参数(还需要符合请求/响应格式)</p>