python 发送上传文件multipart/form-data

{'Content-Length': '1913', 'Content-Type': 'multipart/form-data; 

 boundary=0985630fc9984fb2a0b534d9946a3544'}


from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2


#register_openers()
#datagen, headers = multipart_encode({"name":"1ceshi2ffDf","desc":"测试fff","uploadUtilName":"local-disk","postfix":".exe",\
#                                     "machineTypeIds":"1","version1":1,"version2":"x","version3":1,"version4":1,\
#                                     "attach":open("E:\\Python-Eclipse\\myfoscam\\result\\test_account.html","rb")})
#
#request=urllib2.Request("http://172.16.20.109:50002/firmware/add",datagen, headers)
#response=urllib2.urlopen(request).read()
#print response

你可能感兴趣的:(功能GUI自动化测试)