当前位置 : 主页 > 编程语言 > python >

Python Post img

来源:互联网 收集:自由互联 发布时间:2022-06-15
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.1
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()





上一篇:树莓派python 控制GPIO
下一篇:没有了
网友评论