+登录网页.py输入参数(GET请求)

2024-04-25 18:14:33 发布

您现在位置:Python中文网/ 问答频道 /正文

下面的代码接受一个输入参数t,并返回相同的值。你知道吗

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()

所以当我在浏览器中执行下面的URL时,这是正确的

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

但是当有一个+符号时,它就消除了这个。你知道吗

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

返回

word1 word2

预期结果是什么

word1+word2

我怎样才能防止这种情况?你知道吗


Tags: 代码testimportwebapplocalhosthttp参数