假设你正在发布带有以下内容的html表单:
<input type="text" name="username">
如果使用原始
cgi:
import cgiform = cgi.FieldStorage()print form["username"]
如果使用
Django,Pylons,Flask或
Pyramid:
print request.GET['username'] # for GET form methodprint request.POST['username'] # for POST form method
使用
Turbogears,Cherrypy:
from cherrypy import requestprint request.params['username']
Web.py:
form = web.input()print form.username
Werkzeug:
print request.form['username']
如果使用
Cherrypy或
Turbogears,还可以直接使用参数定义处理程序函数:
def index(self, username): print username
Google App Engine:
class SomeHandler(webapp2.RequestHandler): def post(self): name = self.request.get('username') # this will get the value from the field named username self.response.write(name) # this will write on the document因此,你实际上必须选择这些框架之一。



