Given that the CGI module is depreceated as of Python 3.11 and will be removed in 3.13, and this question is one of the top Google results for "python3 get cgi parameters" here is an example using the proposed replacement (urllib.parse):
#!/usr/bin/python3
## import the required libraries
import os
import urllib.parse
## print a HTTP content header
print('Content-type: text/plain\r\n')
## get the query string. this gets passed to cgi scripts as the environment
## variable QUERY_STRING
query_string = os.environ['QUERY_STRING']
## convert the query string to a dictionary
arguments = urllib.parse.parse_qs(query_string)
## print out the values of each argument
for name in arguments.keys():
## the value is always a list, watch out for that
print(str(name) + ' = ' + str(arguments[name]))
This script assumes that your Python 3 install is located at /usr/bin/python3. You will need to adjust this for non-Linux platforms.
It should be noted that parsing in this way will give you values as a list. Unless you pass the same parameter multiple times, this list will only have one value.
For example, if you are hosting the above CGI script at http ://192.168.0.1/script.cgi:
A request to http ://192.168.0.1/script.cgi?hello=world&foo=bar will give
hello = ['world']
foo = ['bar']
A request to http ://192.168.0.1/script.cgi?hello=world&foo=bar&hello=now will give:
hello = ['world', 'now']
foo = ['bar']