编程语言
首页 > 编程语言> > Python获取Get传值(CGI)

Python获取Get传值(CGI)

作者:互联网

首先配置Apache服务器可处理Python程序,详见:https://www.cnblogs.com/tywusy/p/15862481.html

HTML文件:index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>try it</title>
</head>
<body>
<form action="try.py" method="get">
  <p>name <input type="text" name="fname" /></p>
  <input type="submit" value="Submit" />
</form>
</body>
</html>

Python:try.py

#!C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe
import cgi
form = cgi.FieldStorage()
fn = form.getvalue('fname')
print("Content-type:text/html")
print()
print(fn)

标签:CGI,www,Python,try,html,传值,print,fn
来源: https://www.cnblogs.com/tywusy/p/15864623.html