python : post data within stringIO through poster?
问题 params = {'file': open("test.txt", "rb"), 'name': 'upload test'} datagen, headers = poster.encode.multipart_encode(params) request = urllib2.Request(upload_url, datagen, headers) result = urllib2.urlopen(request) I use poster library to POST for HTTP. It works well. I'm satisfied with that. But I want to try something. As you see above, to send file data, I have to OPEN a file. But is there any way not to make a real file to do that? We can use a STREAM, like StringIO , to deal with data like