pycurl:RETURNTRANSFER选项不存在
我正在使用 pycurl 访问 JSON Web API,但是当我尝试使用以下命令
ocurl.setopt(pycurl.URL, gaurl) # host + endpoint
ocurl.setopt(pycurl.RETURNTRANSFER, 1)
ocurl.setopt(pycurl.HTTPHEADER, gaheader) # Send extra headers
ocurl.setopt(pycurl.CUSTOMREQUEST, "POST") # HTTP POST req
ocurl.setopt(pycurl.CONNECTTIMEOUT, 2)
并执行脚本时,它失败了。
File "getdata.py", line 46, in apicall
ocurl.setopt(pycurl.RETURNTRANSFER, 1)
AttributeError: 'module' object has no attribute 'RETURNTRANSFER'
我不知道发生了什么,也不知道为什么 RETURNTRANSFER 似乎不存在,而所有其他选项都存在。
I'm using pycurl to access a JSON web API, but when I try to use the following:
ocurl.setopt(pycurl.URL, gaurl) # host + endpoint
ocurl.setopt(pycurl.RETURNTRANSFER, 1)
ocurl.setopt(pycurl.HTTPHEADER, gaheader) # Send extra headers
ocurl.setopt(pycurl.CUSTOMREQUEST, "POST") # HTTP POST req
ocurl.setopt(pycurl.CONNECTTIMEOUT, 2)
and execute the script, it fails.
File "getdata.py", line 46, in apicall
ocurl.setopt(pycurl.RETURNTRANSFER, 1)
AttributeError: 'module' object has no attribute 'RETURNTRANSFER'
I haven't a clue what's going on, and why RETURNTRANSFER doesn't appear to exist while all the other options do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该手册显示的用法是类似这样的:
似乎有点迂回,但我不是 PycURL 的忠实粉丝...
The manual shows the usage being something like this:
Seems a little roundabout, but I'm not a big fan of PycURL...
CURLOPT_RETURNTRANSFER 不是 libcurl 选项,它是在 PHP/CURL 绑定中提供的
CURLOPT_RETURNTRANSFER is not a libcurl option, it is but provided within the PHP/CURL binding
您是否尝试过执行
print dir(pycurl)
并查看属性列表中是否存在该选项?Have you tried executing
print dir(pycurl)
and see if the option exists in the attribute list?