2016-05-09 11 views
0

次のコードでは、入力パラメータtを取り、同じ値を返します。+ signはweb.pyの入力パラメータ(GETリクエスト)を排除します

import web 

urls = (
    '/test(.*)', 'test', 

) 
class test(web.storage): 

    def GET(self,r): 
     t = web.input().q 
     print t 
     return t 

if __name__ == "__main__": 

    app = web.application(urls, globals()) 
    app.run() 

私はブラウザ

http://localhost:8080/test?q=word1-word2

しかし、+、それはそれを排除署名がある中で、以下のURLを実行したときにこれが正常に動作します。

http://localhost:8080/test?q=word1+word2

戻る

WORD1のWORD2予想結果が

WORD1 + WORD2

どうすればこの問題を防ぐことができますか?クエリ文字列エンコーディング

答えて

1

するTry URL:+として

http://localhost:8080/test?q=word1%2Bword2 

はスペースを置き換えるために使用されます。

+0

ありがとうございます –

関連する問題