Get form data using python

2019-08-05 05:06发布

问题:

How do i get form data in my Python code. Below is my current code.

import cgitb; cgitb.enable()
import cgi
import sys

form = cgi.FieldStorage()
name = form.getValue('name')
print 'Hello ' + name

回答1:

You were close:

form = cgi.FieldStorage()
name = form['name'].value
print 'Hello ' + name


标签: python cgi