返回-1。在pycurl我得到这个错误
pycurl.error: invalid return value for write callback -1 17
我不知道17意味着什么,但我做得不好?
答案 0 :(得分:3)
:
else if (PyInt_Check(result)) {
long obj_size = PyInt_AsLong(result);
if (obj_size < 0 || obj_size > total_size) {
PyErr_Format(ErrorObject, "invalid return value for write callback %ld %ld", (long)obj_size, (long)total_size);
goto verbose_error;
}
这意味着17是total_size - 这可能吗?和-1(结果)是你的回调返回的。
答案 1 :(得分:1)
import pycurl
import StringIO
c = pycurl.Curl()
s = StringIO.StringIO()
c.setopt(pycurl.URL, url)
c.setopt(pycurl.HEADER, True)
c.setopt(pycurl.NOBODY, True)
c.setopt(pycurl.WRITEFUNCTION, s.write)
c.perform()
print(s.getvalue())