from poster.encode import multipart_encode from poster.streaminghttp import register_openers import urllib2 register_openers() #datagen, headers = multipart_encode({"Img": open("1.jpg", "rb")}) #request = urllib2.Request('http://192.168.0.158:806/API/Det', datagen, headers) #print urllib2.urlopen(request).read() #datagen, headers = multipart_encode( [("key", "value1"), ("key", "value2")] ) a=[ ('Img1', open('1.jpg', 'rb')) ,('Img2', open('2.jpg', 'rb')) ] datagen, headers = multipart_encode( a ) for i in range(100): request = urllib2.Request('http://192.168.0.158:806/API/TwoImage', datagen, headers) print urllib2.urlopen(request).read()