我尝试发布QPixmap图像bia http。为此,我必须让QPixmap保存到临时文件中,并将其作为python文件类读取,执行POST工作。但我认为还有另一种方法可以发布QPixmap。猜猜看,QPixmap保存到StringIO(或其他东西),用它我可以发布。在
现在我就是这样写的。在
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2, os
tmpIm = "c:/tmpIm.png"
PIXMAP.save(tmpIm, "PNG")
register_openers()
_f = open(tmpIm, "rb")
datagen, headers = multipart_encode({"image": _f})
request = urllib2.Request(UPLOAD_URL, datagen, headers)
_rnt = urllib2.urlopen(request)
_f.close()
os.remove(tmpIm)
您可以通过
QBuffer
将QPixmap
保存到QByteArray
,然后将其读入StringIO
对象:相关问题 更多 >
编程相关推荐