Python CGI中的HTTP GET参数问题

约翰·肯尼迪(Johnathan Kennedy)

我正在用Python学习网络开发。当我打开HTML时,我得到了我所期待的Ferrari Fiat Ford,但随后我单击了Ferrari,它以make,model的形式打开了新页面,这不是我想要的。我想要法拉利迪诺。

您能帮我了解一下问题是什么吗?

<!DOCTYPE HTML>
<html lang ="en">
<head>
    <meta charset="UTF-8">
    <title>Python Response</title>
</head>
<body>
    <h1>
       <a href="get.py?make=Ferrarri&model=Dino">Ferrari</a>
       <a href = 'get.py?make = Fiat & model = Topolino'>Fiat</a>
       <a href = 'get.py?make = Ford & model = Mustang'>Ford</a>
    </h1>
</body>
</html>

Python

import cgi

data = cgi.FieldStorage()

make = data.getvalue('make')
model = data.getvalue('model')

print ( 'Content-type:text/html\r\n\r\n' )
print ( '''<!DOCTYPE HTML><html lang = "en">
        <head>
            <meta charset="UTF-8">
            <title>Python Response</title>
        </head>
        <body>
            <h1>, make, model,</h1>
            <a href = "get.html">Back</a>
        </body>
        </html>''' )
Weafs.py

变量不能是字符串。

import cgi

data = cgi.FieldStorage()

make = data.getvalue('make')
model = data.getvalue('model')

print ( 'Content-type:text/html\r\n\r\n' )
print ( '''<!DOCTYPE HTML><html lang = "en">
        <head>
            <meta charset="UTF-8">
            <title>Python Response</title>
        </head>
        <body>
            <h1>, ''' + make + ', ' + model + ''',</h1>
            <a href = "get.html">Back</a>
        </body>
        </html>''' )

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在Python http服务器上执行perl / cgi的问题

来自分类Dev

在 Python cgi 中设置浏览器 cookie 的问题

来自分类Dev

Python中的原始CGI

来自分类Dev

golang中访问GET参数net / http的问题

来自分类Dev

在使用$ http的AngualrJS中,如何获取Python CGI中变量集的值?

来自分类Dev

在Python中覆盖__get__的问题

来自分类Dev

Python:参数中的随机琐事琐事问题/答案

来自分类Dev

Python定义参数问题

来自分类Dev

Python线程参数问题

来自分类Dev

express 中的 app.get() 函数参数问题

来自分类Dev

从apache cgi python接收http发布请求的xml内容

来自分类Dev

如何使用python http.server运行CGI“ hello world”

来自分类Dev

无法访问 Python 3.6 中的命令行参数;python启动器的问题?

来自分类Dev

脚本中的参数问题

来自分类Dev

脚本中的参数问题

来自分类Dev

在get url python中传递dataframe列vale作为参数

来自分类Dev

GET请求忽略了我在python请求中的参数

来自分类Dev

Angular HTTP get 中的 Corrs 问题

来自分类Dev

使用CGI-python有问题查找模块

来自分类Dev

在Warp中处理HTTP GET查询参数

来自分类Dev

AngularJS $ http.get('')中缺少参数

来自分类Dev

在Warp中处理HTTP GET查询参数

来自分类Dev

AngularJS $ http.get('')中缺少参数

来自分类Dev

Apache服务器中的Python Cgi脚本

来自分类Dev

使用Pandas从Python CGI脚本中读取上传的XLSX文件

来自分类Dev

如何遍历python cgi中的表单值?新手

来自分类Dev

在os.system之后清除Python CGI中的stdout

来自分类Dev

脚本头过早结束python cgi脚本中的错误

来自分类Dev

在python cgi-bin中调用外部函数