Is there a Python equivalent of PHP's $_GET[] and $_POST[]?



I’m using python and apache2.

I’d like to write a script called that when accessed at, prints the string ‘bar’

I’m thinking it should be like this:

def index(req):


The is the part I’m asking about.


You can use fieldstorage in cgi for ex :

if the url is :


# Import modules for CGI handling 
import cgi, cgitb 

# Create instance of FieldStorage 
form = cgi.FieldStorage() 

# Get data from fields
first_name = form.getvalue('first_name')
last_name  = form.getvalue('last_name')

Answered By – curiousguy

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More