【python】python-cgi数据提交与接受

HTMl数据提交

<form method="get" action="">
	<input type="text" name="firstname" placeholder="firstname" >
	<input type="text" placeholder="lastname">
	<br>
	<input type="submit" value="提交">
</form>

python-cgi获取表单数据

import cgi;
print ("Content-type:text/html;charset=utf-8\n");
#创建表单对象
form = cgi.FieldStorage();
#获取表单数据
firstname = form.getvalue("firstname");
lastname = form.getvalue("lastname");

你可能感兴趣的:(python,linux)