获取具有不允许在变量中使用的字符的post参数网页.py

2024-04-25 10:12:34 发布

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

我正在尝试将google reCaptcha集成到我的站点中,当我意识到提交所需的POST参数有一个不合法的字符“例如减号运算符”。你知道吗

以下是项目代码:

class apply:
    def POST(self):
        i = web.input()        

        print recaptcha2.verify("mySecretKey",i.g-recaptcha-response, "end user's ip")

我遇到的问题涉及到g-repactcha-response POST参数,以及它是如何使用在python变量中不合法的字符的变量。你知道吗

有办法解决这个问题吗?你知道吗

更新: 这是我面临的错误的一个例子

Traceback (most recent call last):   File "C:\Python27\lib\site-packages\web\application.py", line 236, in process
    return self.handle()   File "C:\Python27\lib\site-packages\web\application.py", line 227, in handle
    return self._delegate(fn, self.fvars, args)   File "C:\Python27\lib\site-packages\web\application.py", line 409, in
_delegat e
    return handle_class(cls)   File "C:\Python27\lib\site-packages\web\application.py", line 384, in handle_c lass
    return tocall(*args)   File "C:\Users\Administrator\Desktop\Web App - Copy\bin\app.py", line 42, in P OST
    print recaptcha2.verify("mySecretKey", i.g-recaptcha-response, us_ip)   File "C:\Python27\lib\site-packages\web\utils.py", line 76, in \__getattr__
    raise AttributeError, k AttributeError: 'g'

myServerIP - - [27/Jun/2015 05:20:23] "HTTP/1.1 POST /apply_check" - 5 00 Internal Server Error

Tags: inpyselfwebreturnapplicationresponselib
1条回答
网友
1楼 · 发布于 2024-04-25 10:12:34

通过在一个变量中引用POST数据,我能够获得作为g-repactcha-response发送的POST数据网络输入()对象 e、 g

i = web.input()
i['g-recaptcha-response']

相关问题 更多 >

    热门问题