[問題] 用cgi.FieldStorage取form時遇到#符號

看板Python作者 (Yow)時間12年前 (2012/06/14 10:04), 編輯推噓1(105)
留言6則, 2人參與, 最新討論串1/1
環境是 WIN2003的IIS + Python form表單上有 id、pwd、server 三個INPUT 送出 form 表單後 ,用 form=cgi.FieldStorage() 取值 然後 print form 出來看 出現: FieldStorage(None, None, [MiniFieldStorage('id', 'zzz'), MiniFieldStorage('pwd', 'xxx')]) 而實際上 pwd 的值 應該是 xxx#ccc 井字號之後的資料都不見了 然後在後面處理字串時網頁上會出現 string.upper(string.replace(login_form.getvalue("server"),' ','')) File "C:\Python22\Lib\string.py", line 370, in replace return s.replace(old, new, maxsplit) AttributeError: 'NoneType' object has no attribute 'replace' 請問該怎麼處理 # 後面字串不見的狀況? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.211.33.254

06/14 10:09, , 1F
不好意思~修正一下~
06/14 10:09, 1F

06/14 10:10, , 2F
form=cgi.FieldStorage() 取到的是URL參數
06/14 10:10, 2F

06/14 10:10, , 3F
在前一頁有把form轉成URL參數
06/14 10:10, 3F

06/14 10:11, , 4F
不過出現 # 後面的值通通取不到
06/14 10:11, 4F

06/17 02:03, , 5F
最簡單的是改用 POST
06/17 02:03, 5F

06/17 02:06, , 6F
網址的#以後是頁內錨點 瀏覽器是不會送到server的
06/17 02:06, 6F
文章代碼(AID): #1FsKQR9k (Python)