2010-12-06 41 views
0

我在緩衝區中有圖像數據我想通過不使用庫將圖像保存在我的計算機中。 (我使用python 3.1) 非常感謝。在python中保存圖像3.1

+1

確實python 3.x不支持打開?如果這樣做,那麼`f = open('file','w'); f.write(imagedate); f.close();` – 2010-12-06 08:10:17

回答

0

好了,在Python 3.x都有內置的open功能化名爲io.open所以你可以做(​​假設你有存儲在imagedata圖像數據)

filename = "image.png" # use suitable extension according to the format of the image 
f = open('filename', 'w') 
f.write(imagedate) 
f.close() 

現在的圖像將被保存在本地目錄,文件名爲image.png

+0

咦?在PEP 3116中沒有這樣的陳述。 – 2010-12-06 10:09:26