【发布时间】:2015-03-04 17:17:46
【问题描述】:
其他人注意到 pycurl 示例在 Python 2.* 上不起作用吗?
import pycurl
from StringIO import StringIO
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://pycurl.sourceforge.net/')
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
body = buffer.getvalue()
# Body is a string in some encoding.
# In Python 2, we can print it without knowing what the encoding is.
print(body)
然后我遇到这样的失败
Traceback (most recent call last):
File "./get_python2.py", line 9, in <module>
c.setopt(c.WRITEDATA, buffer)
TypeError: invalid arguments to setopt
分配 WRITEFUNCTION 和其他功能似乎与宣传的一样。有人知道这里发生了什么吗?
【问题讨论】: