看板 Python 關於我們 聯絡資訊
各位大大 ,小的在學習python有一些問題 就是我現在在某個html有多個form 在選定完我想要的form之後 按下去會對應到一個xxx.py檔上做執行 我要怎麼在xxx.py上抓到我從html上輸入的資料呢? 還是我在建立多個form的時候要做些手腳? -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.217.224
darkgerm:你是說用 python 寫 cgi 嗎?要讀環境變數 query_string 12/19 22:38
darkgerm:有 urlparse.parse_qs() 可以幫你 parse 參數 12/19 22:39
seanptt:import cgi 12/19 23:31
seanptt:form = cgi.FieldStorage() 12/19 23:31
seanptt:userid = cgi.escape(form['UserID'].value) 12/19 23:32