Save image in python 3.1
I have image da开发者_StackOverflow中文版ta in buffer I want to save image in my computer by don't use library. (I use python 3.1) Thank you so much.
Okay, in python 3.x the built in open
function is aliased to io.open
so you can do ( assuming you have image data stored in imagedata
)
filename = "image.png" # use suitable extension according to the format of the image
f = open(filename, 'w') # first argument is the filename
f.write(imagedate)
f.close()
Now the image will be saved in the local directory with file name image.png
.
精彩评论