日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python中通過CGI傳遞信息

CGI(Common Gateway Interface),即通用網(wǎng)關(guān)接口,是 WWW(World Wide Web)技術(shù)中最重要的技術(shù)之一,是外部應(yīng)用程序(即 CGI 程序)與 Web 服務(wù)器之間的接口標(biāo)準(zhǔn),負(fù)責(zé)在 CGI 程序和 Web 服務(wù)器之間傳遞信息。

通過CGI程序傳遞checkbox數(shù)據(jù)

checkbox用于提交一個或者多個選項數(shù)據(jù),HTML代碼如下:

nbsp;html>



  "utf-8">
菜鳥教程(runoob.com)
  
   "/cgi-bin/checkbox.py" method=
   "POST" target=
   "_blank"> 
   type=
   "checkbox" name=
   "runoob" value=
   "on" /> 菜鳥教程 
   type=
   "checkbox" name=
   "google" value=
   "on" /> Google 
   type=
   "submit" value=
   "選擇站點" /> 
  


以下為 checkbox.py 文件的代碼:

#!/usr/bin/python3

# 引入 CGI 處理模塊
import cgi, cgitb

# 創(chuàng)建 FieldStorage的實例
form = cgi.FieldStorage()

# 接收字段數(shù)據(jù)
if form.getvalue('google'):
google_flag = "是"
else:
google_flag = "否"

if form.getvalue('runoob'):
runoob_flag = "是"
else:
runoob_flag = "否"

print ("Content-type:text/html")
print ()
print ("")print ("")
print ("")
print ("")
print ("")print ("")
print (" 

修改 checkbox.py 權(quán)限:

chmod 755 checkbox.py

通過CGI程序傳遞Radio數(shù)據(jù)

Radio 只向服務(wù)器傳遞一個數(shù)據(jù),HTML代碼如下:

nbsp;html>



  "utf-8">
菜鳥教程(runoob.com)
  
   "/cgi-bin/radiobutton.py" method=
   "post" target=
   "_blank"> 
   type=
   "radio" name=
   "site" value=
   "runoob" /> 菜鳥教程 
   type=
   "radio" name=
   "site" value=
   "google" /> Google 
   type=
   "submit" value=
   "提交" /> 
  


radiobutton.py 代碼如下:

#!/usr/bin/python3

# 引入 CGI 處理模塊
import cgi, cgitb

# 創(chuàng)建 FieldStorage的實例
form = cgi.FieldStorage()

# 接收字段數(shù)據(jù)
if form.getvalue('site'):
  site = form.getvalue('site')
else:
  site = "提交數(shù)據(jù)為空"

print ("Content-type:text/html")
print ()
print ("")
print ("")
print ("")
print ("")
print ("")
print ("")
print (" 

修改 radiobutton.py 權(quán)限:

chmod 755 radiobutton.py

通過CGI程序傳遞 Textarea 數(shù)據(jù)

Textarea 向服務(wù)器傳遞多行數(shù)據(jù),HTML代碼如下:

nbsp;html>



  "utf-8">
菜鳥教程(runoob.com)
  
   "/cgi-bin/textarea.py" method=
   "post" target=
   "_blank"> 
   "textcontent" cols="40" rows="4">
在這里輸入內(nèi)容...

   type=
   "submit" value=
   "提交" /> 
  


textarea.py 代碼如下:

#!/usr/bin/python3

# 引入 CGI 處理模塊
import cgi, cgitb

# 創(chuàng)建 FieldStorage的實例
form = cgi.FieldStorage()

# 接收字段數(shù)據(jù)
if form.getvalue('textcontent'):
  text_content = form.getvalue('textcontent')
else:
  text_content = "沒有內(nèi)容"

print ("Content-type:text/html")
print ()
print ("")
print ("")
print ("")
print ("")
print ("")
print ("")
print (" 

修改 textarea.py 權(quán)限:

chmod 755 textarea.py

通過CGI程序傳遞下拉數(shù)據(jù)

HTML 下拉框代碼如下:

nbsp;html>



  "utf-8">
菜鳥教程(runoob.com)
  
   "/cgi-bin/dropdown.py" method=
   "post" target=
   "_blank"> 
   "dropdown"> "runoob" selected>菜鳥教程"google">Google
   type=
   "submit" value=
   "提交"/> 
  


dropdown.py 代碼如下所示:

#!/usr/bin/python3

# 引入 CGI 處理模塊
import cgi, cgitb

# 創(chuàng)建 FieldStorage的實例
form = cgi.FieldStorage()

# 接收字段數(shù)據(jù)
if form.getvalue('dropdown'):
  dropdown_value = form.getvalue('dropdown')
else:
  dropdown_value = "沒有內(nèi)容"

本文題目:Python中通過CGI傳遞信息
網(wǎng)站路徑:http://www.5511xx.com/article/djhceeh.html