本文介绍了将html表单值发布到python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了带有文本框和按钮的html表单
输入您的搜索关键字
我的要求是将文本框的值传递给我的test.py代码,有没有办法做到这一点。 请告诉我它是如何做到的。 ,放置你的CGI脚本的位置,文本框的值将被传递给CGI脚本。 eg。
< form name =searchaction =/ cgi-bin / test.py方法= GET > 搜寻:< input type =textname =searchbox> < input type =submitvalue =提交> < / form>在您的test.py中
import cgi form = cgi.FieldStorage() searchterm = form.getvalue('searchbox')因此,您将在python的searchterm变量的搜索文本框中输入关键字。
I have created html form with text box and button
enter ur search keyword
My requirement is to pass the text box value in to my test.py code, is there any way to do it. Please suggest me how do it.
解决方案in the form action form action="", put the location of your cgi script and the value of the textbox will be passed to the cgi script. eg.
<form name="search" action="/cgi-bin/test.py" method="get"> Search: <input type="text" name="searchbox"> <input type="submit" value="Submit"> </form>in your test.py
import cgi form = cgi.FieldStorage() searchterm = form.getvalue('searchbox')thus you will get the key word entered in search text box in searchterm variable in python.
更多推荐
将html表单值发布到python脚本
发布评论