以下是上传文件的代码:
file_size = os.path.getsize('Tea.rdf')
f = file('Tea.rdf')
c = pycurl.Curl()
c.setopt(pycurl.URL, 'http://localhost:8080/openrdf-sesame/repositories/rep/statements')
c.setopt(pycurl.HTTPHEADER, ["Content-Type: application/rdf+xml;charset=UTF-8"])
c.setopt(pycurl.PUT, 1)
c.setopt(pycurl.INFILE, f)
c.setopt(pycurl.INFILESIZE, file_size)
c.perform()
c.close()
现在,我一点也不喜欢使用PycURL。你能建议任何替代品吗?也许urllib2或httplib可以做同样的事情?你能写一些示例代码吗?
非常感谢!