我正在使用PyCurl发送带有文件附件的POST请求:
d = pycurl.Curl()
d.setopt(pycurl.URL, url)
# d.setopt(pycurl.RETURNTRANSFER, True)
d.setopt(pycurl.POST, True)
d.setopt(pycurl.POSTFIELDS, {filename: "@" + filename})
b = StringIO.StringIO()
d.setopt(pycurl.WRITEFUNCTION, b.write)
d.perform()
d.close()
message = b.getvalue()
我得到:
Something went wrong, invalid arguments to setopt
Traceback (most recent call last):
File "hasoff.py", line 214, in create_offers_for_advertiser
if filename:
TypeError: invalid arguments to setopt
有什么问题吗?
pycurl
中使用 PHP 特定的@$filename
。 - Mikhail Gerasimov