小编mas*_*cat的帖子

使用Requests Python包的钩子问题

我正在使用该模块requests,当我开始使用钩子时,我收到了这条消息.

File "/Library/Python/2.7/site-packages/requests-1.1.0-py2.7.egg/requests/sessions.py", line 321, in request
resp = self.send(prep, **send_kwargs)

File "/Library/Python/2.7/site-packages/requests-1.1.0-py2.7.egg/requests/sessions.py", line 426, in send
r = dispatch_hook('response', hooks, r, **kwargs)

File "/Library/Python/2.7/site-packages/requests-1.1.0-py2.7.egg/requests/hooks.py", line 41, in dispatch_hook
_hook_data = hook(hook_data, **kwargs)
TypeError: hook() got an unexpected keyword argument 'verify'
Run Code Online (Sandbox Code Playgroud)

这是我的代码(简化):

import requests
def hook(r):
     print r.json()

r = requests.get("http://search.twitter.com/search.json?q=blue%20angels&rpp=5", hooks=dict(response=hook))
Run Code Online (Sandbox Code Playgroud)

python request typeerror python-2.7 python-3.x

6
推荐指数
1
解决办法
4576
查看次数

标签 统计

python ×1

python-2.7 ×1

python-3.x ×1

request ×1

typeerror ×1